STRTOD(3) — C LIBRARY FUNCTIONS
NAME
strtod, atof − convert string to double-precision number
SYNOPSIS
double strtod(str, ptr)
char ∗str, ∗∗ptr;
double atof(str)
char ∗str;
DESCRIPTION
strtod() returns as a double-precision floating-point number the value represented by the character string pointed to by str. The string is scanned up to the first unrecognized character, using string_to_decimal(3), with fortran_conventions set to 0.
If the value of ptr is not (char ∗∗)NULL, a pointer to the character terminating the scan is returned in the location pointed to by ptr. If no number can be formed, ∗ptr is set to str, and for historical compatibility, 0.0 is returned, although a NaN would better match the IEEE Floating-Point Standard’s intent.
atof(str) is equivalent to strtod(str, (char ∗∗)NULL). Thus, when atof(str) returns 0.0 there is no way to determine whether str contained a valid numerical string representing 0.0 or an invalid numerical string.
SEE ALSO
scanf(3S), string_to_decimal(3)
DIAGNOSTICS
Exponent overflow and underflow produce the results specified by the IEEE Standard. In addition, errno is set to ERANGE.
Sun Release 4.0 — Last change: 22 November 1987