strtod(3C) strtod(3C)
NAME
strtod, atof - convert string to double-precision number
SYNOPSIS
#include <stdlib.h>
double strtod(const char *nptr, char **endptr);
double atof(const char *nptr);
DESCRIPTION
strtod() returns as a double-precision floating-point number (double)
the value represented by the character string pointed to by nptr. The
string is scanned up to the first unrecognized character.
strstr() recognizes an optional string of "white-space" characters [as
defined by isspace() in ctype(3C)], then an optional sign, then a
string of digits optionally containing a decimal point character, then
an optional exponent part including an e or E followed by an optional
sign, followed by an integer.
If the value of endptr is not (char **)NULL, a pointer to the charac-
ter terminating the scan is returned in the location pointed to by
endptr. If no number can be formed, *endptr is set to nptr, and zero
is returned.
atof(nptr) is equivalent to:
strtod(nptr, (char **)NULL).
If the return value of atof() cannot be represented, behavior is unde-
fined.
RESULT
If the correct value would cause overflow - and when the -kansi or
-kosi compilation options were used -, HUGEVAL (defined in math.h) is
returned (according to the sign of value), and errno is set to ERANGE.
[When the -kcc (default) compilation option is used, HUGE is returned
instead of HUGEVAL.]
If the correct value would cause underflow, zero is returned and errno
is set to ERANGE.
NOTES
If the result of atof() is undefined because the return value cannot
be represented, you should use the strtod() function instead.
SEE ALSO
cc(1), ctype(3C), strtol(3C), scanf(3S).
Page 1 Reliant UNIX 5.44 Printed 11/98