xref: /csrg-svn/lib/libc/stdlib/strtod.3 (revision 48349)
1*48349Scael.\" Copyright (c) 1990, 1991 The Regents of the University of California.
242114Sbostic.\" All rights reserved.
342114Sbostic.\"
442114Sbostic.\" %sccs.include.redist.man%
542114Sbostic.\"
6*48349Scael.\"     @(#)strtod.3	5.2 (Berkeley) 04/19/91
742114Sbostic.\"
8*48349Scael.Dd
9*48349Scael.Dt STRTOD 3
10*48349Scael.Os
11*48349Scael.Sh NAME
12*48349Scael.Nm strtod
13*48349Scael.Nd convert
14*48349Scael.Tn ASCII
15*48349Scaelstring to double
16*48349Scael.Sh SYNOPSIS
17*48349Scael.Fd #include <stdlib.h>
18*48349Scael.Ft double
19*48349Scael.Fn strtod "const char *nptr" "char **endptr"
20*48349Scael.Sh DESCRIPTION
2142114SbosticThe
22*48349Scael.Fn strtod
2342114Sbosticfunction converts the initial portion of the string
2442114Sbosticpointed to by
25*48349Scael.Fa nptr
2642114Sbosticto
27*48349Scael.Em double
2842114Sbosticrepresentation.
29*48349Scael.Pp
3042114SbosticThe expected form of the string is an optional plus (``+'') or minus
31*48349Scaelsign (``-'') followed by a sequence of digits optionally containing
3242114Sbostica decimal-point character, optionally followed by an exponent.
3342114SbosticAn exponent consists of an ``E'' or ``e'', followed by an optional plus
3442114Sbosticor minus sign, followed by a sequence of digits.
35*48349Scael.Pp
3642114SbosticLeading white-space characters in the string (as defined by the
37*48349Scael.Xr isspace 3
3842114Sbosticfunction) are skipped.
39*48349Scael.Sh RETURN VALUES
4042114SbosticThe
41*48349Scael.Fn strtod
4242114Sbosticfunction returns the converted value, if any.
43*48349Scael.Pp
4442114SbosticIf
45*48349Scael.Fa endptr
46*48349Scaelis not
47*48349Scael.Dv NULL ,
48*48349Scaela pointer to the character after the last character used
4942114Sbosticin the conversion is stored in the location referenced by
50*48349Scael.Fa endptr .
51*48349Scael.Pp
5242114SbosticIf no conversion is performed, zero is returned and the value of
53*48349Scael.Fa nptr
5442114Sbosticis stored in the location referenced by
55*48349Scael.Fa endptr .
56*48349Scael.Pp
5742114SbosticIf the correct value would cause overflow, plus or minus
58*48349Scael.Dv HUGE_VAL
5942114Sbosticis returned (according to the sign of the value), and
60*48349Scael.Dv ERANGE
6142114Sbosticis stored in
62*48349Scael.Va errno .
6342114SbosticIf the correct value would cause underflow, zero is
6442114Sbosticreturned and
65*48349Scael.Dv ERANGE
6642114Sbosticis stored in
67*48349Scael.Va errno .
68*48349Scael.Sh ERRORS
69*48349Scael.Bl -tag -width [ERANGE]
70*48349Scael.It Bq Er ERANGE
7142114SbosticOverflow or underflow occurred.
72*48349Scael.Sh SEE ALSO
73*48349Scael.Xr atof 3 ,
74*48349Scael.Xr atoi 3 ,
75*48349Scael.Xr atol 3 ,
76*48349Scael.Xr strtol 3 ,
77*48349Scael.Xr strtoul 3
78*48349Scael.Sh STANDARDS
79*48349ScaelThe
80*48349Scael.Fn strtod
81*48349Scaelfunction
82*48349Scaelconforms to
83*48349Scael.St -ansiC .
84*48349Scael.Sh BUGS
8542114SbosticThis manual page represents intent instead of actual practice.
8642114SbosticThe
87*48349Scael.Fn strtod
8842114Sbosticfunction is not currently available.
89