148349Scael.\" Copyright (c) 1990, 1991 The Regents of the University of California. 242114Sbostic.\" All rights reserved. 342114Sbostic.\" 4*50329Sbostic.\" This code is derived from software contributed to Berkeley by 5*50329Sbostic.\" the American National Standards Committee X3, on Information 6*50329Sbostic.\" Processing Systems. 7*50329Sbostic.\" 842114Sbostic.\" %sccs.include.redist.man% 942114Sbostic.\" 10*50329Sbostic.\" @(#)strtod.3 5.3 (Berkeley) 06/29/91 1142114Sbostic.\" 1248349Scael.Dd 1348349Scael.Dt STRTOD 3 1448349Scael.Os 1548349Scael.Sh NAME 1648349Scael.Nm strtod 1748349Scael.Nd convert 1848349Scael.Tn ASCII 1948349Scaelstring to double 2048349Scael.Sh SYNOPSIS 2148349Scael.Fd #include <stdlib.h> 2248349Scael.Ft double 2348349Scael.Fn strtod "const char *nptr" "char **endptr" 2448349Scael.Sh DESCRIPTION 2542114SbosticThe 2648349Scael.Fn strtod 2742114Sbosticfunction converts the initial portion of the string 2842114Sbosticpointed to by 2948349Scael.Fa nptr 3042114Sbosticto 3148349Scael.Em double 3242114Sbosticrepresentation. 3348349Scael.Pp 3442114SbosticThe expected form of the string is an optional plus (``+'') or minus 3548349Scaelsign (``-'') followed by a sequence of digits optionally containing 3642114Sbostica decimal-point character, optionally followed by an exponent. 3742114SbosticAn exponent consists of an ``E'' or ``e'', followed by an optional plus 3842114Sbosticor minus sign, followed by a sequence of digits. 3948349Scael.Pp 4042114SbosticLeading white-space characters in the string (as defined by the 4148349Scael.Xr isspace 3 4242114Sbosticfunction) are skipped. 4348349Scael.Sh RETURN VALUES 4442114SbosticThe 4548349Scael.Fn strtod 4642114Sbosticfunction returns the converted value, if any. 4748349Scael.Pp 4842114SbosticIf 4948349Scael.Fa endptr 5048349Scaelis not 5148349Scael.Dv NULL , 5248349Scaela pointer to the character after the last character used 5342114Sbosticin the conversion is stored in the location referenced by 5448349Scael.Fa endptr . 5548349Scael.Pp 5642114SbosticIf no conversion is performed, zero is returned and the value of 5748349Scael.Fa nptr 5842114Sbosticis stored in the location referenced by 5948349Scael.Fa endptr . 6048349Scael.Pp 6142114SbosticIf the correct value would cause overflow, plus or minus 6248349Scael.Dv HUGE_VAL 6342114Sbosticis returned (according to the sign of the value), and 6448349Scael.Dv ERANGE 6542114Sbosticis stored in 6648349Scael.Va errno . 6742114SbosticIf the correct value would cause underflow, zero is 6842114Sbosticreturned and 6948349Scael.Dv ERANGE 7042114Sbosticis stored in 7148349Scael.Va errno . 7248349Scael.Sh ERRORS 7348349Scael.Bl -tag -width [ERANGE] 7448349Scael.It Bq Er ERANGE 7542114SbosticOverflow or underflow occurred. 7648349Scael.Sh SEE ALSO 7748349Scael.Xr atof 3 , 7848349Scael.Xr atoi 3 , 7948349Scael.Xr atol 3 , 8048349Scael.Xr strtol 3 , 8148349Scael.Xr strtoul 3 8248349Scael.Sh STANDARDS 8348349ScaelThe 8448349Scael.Fn strtod 8548349Scaelfunction 8648349Scaelconforms to 8748349Scael.St -ansiC . 8848349Scael.Sh BUGS 8942114SbosticThis manual page represents intent instead of actual practice. 9042114SbosticThe 9148349Scael.Fn strtod 9242114Sbosticfunction is not currently available. 93