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