strtod, atof
Purpose
Converts an ASCII string to a floating-point number.
Library
Standard C Library (libc.a)
Syntax
double strtod (nptr, ptr) double atof (nptr)
char *nptr, **ptr; char *nptr;
Description
The strtod and atof subroutines convert a character
string, pointed to by the nptr parameter, to a double-
precision floating-point number. The first unrecognized
character ends the conversion.
These subroutines recognize a character string when the
characters appear in the following order:
1. An optional string of white-space characters
2. An optional sign
3. A string of digits optionally containing a decimal
point
4. An optional e or E followed by an optionally signed
integer.
If the string begins with an unrecognized character,
strtod and atof return the value 0.
If the value of ptr is not (char **) NULL, then a pointer
to the character that terminated the scan is stored in
*ptr. If an integer cannot be formed, *ptr is set to
nptr, and 0 is returned.
If the correct return value overflows, strtod and atof
return INF. On underflow, strtod and atof return 0.
The atof (nptr) subroutine call is equivalent to strtod
(nptr, (char **) NULL).
The strtod and atof subroutines perform conversions to a
floating-point number. See "strtol, atol, atoi" for
information on conversions to integers.
Related Information
In this book: "scanf, fscanf, sscanf, NLscanf, NLfscanf,
NLsscanf" and "strtol, atol, atoi."