|
|
#include <stdlib.h>double strtod (const char str, char ptr);
long double strtold (const char str, char ptr);
double atof (const char str);
strtod 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 [as specified by the current locale; see setlocale(3C)], then an optional exponent part including an e or E followed by an optional sign, followed by an integer.
If the value of ptr is not (char )0, 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 zero is returned.
On the processors that support strtold, this function is equivalent to strtod, except that it returns a long double-precision floating-point number.
atof(str) is equivalent to:
strtod(str, (char )0)
If the correct value would cause underflow, zero is returned and errno is set to ERANGE.
When the -Xt compilation options are used [see cc(1)], a value that compares equal to ±HUGE is returned instead of ±HUGE_VAL.