xref: /original-bsd/lib/libc/stdlib/strtod.3 (revision bd226a66)
1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" the American National Standards Committee X3, on Information
6.\" Processing Systems.
7.\"
8.\" %sccs.include.redist.man%
9.\"
10.\"     @(#)strtod.3	5.3 (Berkeley) 06/29/91
11.\"
12.Dd
13.Dt STRTOD 3
14.Os
15.Sh NAME
16.Nm strtod
17.Nd convert
18.Tn ASCII
19string to double
20.Sh SYNOPSIS
21.Fd #include <stdlib.h>
22.Ft double
23.Fn strtod "const char *nptr" "char **endptr"
24.Sh DESCRIPTION
25The
26.Fn strtod
27function converts the initial portion of the string
28pointed to by
29.Fa nptr
30to
31.Em double
32representation.
33.Pp
34The expected form of the string is an optional plus (``+'') or minus
35sign (``-'') followed by a sequence of digits optionally containing
36a decimal-point character, optionally followed by an exponent.
37An exponent consists of an ``E'' or ``e'', followed by an optional plus
38or minus sign, followed by a sequence of digits.
39.Pp
40Leading white-space characters in the string (as defined by the
41.Xr isspace 3
42function) are skipped.
43.Sh RETURN VALUES
44The
45.Fn strtod
46function returns the converted value, if any.
47.Pp
48If
49.Fa endptr
50is not
51.Dv NULL ,
52a pointer to the character after the last character used
53in the conversion is stored in the location referenced by
54.Fa endptr .
55.Pp
56If no conversion is performed, zero is returned and the value of
57.Fa nptr
58is stored in the location referenced by
59.Fa endptr .
60.Pp
61If the correct value would cause overflow, plus or minus
62.Dv HUGE_VAL
63is returned (according to the sign of the value), and
64.Dv ERANGE
65is stored in
66.Va errno .
67If the correct value would cause underflow, zero is
68returned and
69.Dv ERANGE
70is stored in
71.Va errno .
72.Sh ERRORS
73.Bl -tag -width [ERANGE]
74.It Bq Er ERANGE
75Overflow or underflow occurred.
76.Sh SEE ALSO
77.Xr atof 3 ,
78.Xr atoi 3 ,
79.Xr atol 3 ,
80.Xr strtol 3 ,
81.Xr strtoul 3
82.Sh STANDARDS
83The
84.Fn strtod
85function
86conforms to
87.St -ansiC .
88.Sh BUGS
89This manual page represents intent instead of actual practice.
90The
91.Fn strtod
92function is not currently available.
93