atof() — Convert character string to double
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
ISO C
POSIX.1 XPG4 XPG4.2 C99 Single UNIX Specification, Version 3 |
both |
Format
#include <stdlib.h>
double atof(const char *nptr);
General description
The atof() function converts the initial portion of
the string pointed to by nptr to a 'double'.
This is equivalent to
strtod(nptr, (char**)NULL)
The double value is either hexadecimal floating point or binary floating point, depending on the floating point mode of the thread invoking the atof() function. This function uses _isBF() to determine the floating point mode of the invoking thread.
See the “fscanf Family of Formatted Input Functions” on fscanf(), scanf(), sscanf() — Read and format data for a description of special infinity and NaN sequences recognized by z/OS® formatted input functions, including atof() and strtod() in IEEE Binary Floating-Point mode.
Returned value
The atof() function returns the converted value if the value can be represented, otherwise the return value is undefined.
Related information
- stdlib.h — Standard library functions
- atoi() — Convert character string to integer
- atol() — Convert character string to long
- fscanf(), scanf(), sscanf() — Read and format data
- __isBFP() — Determine application floating-point format
- strtod() — Convert character string to double
- strtol() — Convert character string to long
- strtoul() — Convert string to unsigned integer