Your Browser is not longer supported
Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...
{{viewport.spaceProperty.prod}}
atof - convert string to double-precision number
&pagelevel(4)&pagelevel
Syntax | #include <stdlib.h> double atof(const char *str); |
Description | atof() converts an EBCDIC string pointed to by str into a floating-point number of type double . The string to be converted may be formatted as follows: [{ tab| 'BLANK'}...][+|-][ digit...][.][ digit...][{E|e}[+|-] digit...]
or
[{ tab| 'BLANK'}...][+|-]0{X|x}[ hexdigit...][.][ hexdigit...][{P|p}[+|-] digit ...]
All control characters for white space are legal for tab (see definition under isspace() ). The atof(str) function differs from strtod(str,(char**)NULL) only in error handling. |
Return val. | Floating-point number of type double |
| for strings formatted as described above and representing a numeric value that is within the permissible floating point range. |
Extension 0 HUGE_VAL
| for strings which do not correspond to the syntax described above. for strings whose numeric value lies outside the permissible floating-point range. errno is set to indicate the error. |
Errors | atof() will fail if:
ERANGE The return value causes an overflow or underflow. (End)
|
Notes | atof() is completely contained in strtod() . However, the function continues to be offered because it is used in many existing applications. The decimal character in the string to be converted is affected by the locale (category
LC_NUMERIC ). The decimal point is the default.
atof() also recognizes strings that begin with digits but then end with any character.
atof() cuts off the numeric part, converts it according to the above description, and ignores the rest.
|
See also | atoi() , atol() , strtod() , strtol() , strtoul() , stdlib.h .
|