Manual Page Result
0
Command: atof | Section: 3 | Source: Digital UNIX | File: atof.3.gz
atof(3) Library Functions Manual atof(3)
NAME
atof, strtod - Converts a character string to a double-precision float-
ing-point value
LIBRARY
Standard C Library (libc.a)
SYNOPSIS
#include <stdlib.h>
double atof(
const char *nptr) ;
double strtod(
const char *nptr,
char **endptr) ;
PARAMETERS
Points to the character string to convert. Specifies either a null
value, or a pointer to the character that ended the scan or to a null
value.
DESCRIPTION
The atof() function converts the string pointed to by the nptr parame-
ter up to the first character that is inconsistent with the format of a
floating-point number to a double floating-point value. Leading white-
space characters are ignored. A call to this function is equivalent to
a call to strtod(nptr, (char **) NULL), except for error handling.
When the value cannot be represented, the result is undefined.
The strtod() function converts the initial portion of the string
pointed to by the nptr parameter to double representation. First the
input string is decomposed into the following three parts: An initial,
possibly empty, sequence of white-space characters (as specified by the
isspace() function). A subject sequence interpreted as a floating-
point constant. A final string of one or more unrecognized characters,
including the terminating null character of the input string.
After decomposition of the string, the subject sequence is converted to
a floating-point number, and the resulting value is returned. A sub-
ject sequence is defined as the longest initial subsequence of the in-
put string, starting with the first nonwhite-space character, that is
of the expected form. The expected form and order of the subject se-
quence is: An optional plus (+) or minus (-) sign. A sequence of dig-
its optionally containing a radix character. An optional exponent
part. An exponent part consists of e or E, followed by an optional
sign, which is followed by one or more decimal digits.
When the input string is empty or consists entirely of white space, or
when the first nonwhite-space character is other than a sign, a digit,
or a radix character, the subject sequence contains no characters.
For the strtod() function, when the value of the endptr parameter is
not (char**) NULL, a pointer to the character that terminated the scan
is stored at *endptr.
When a floating-point value cannot be formed, *endptr is set to nptr.
NOTES
The setlocale() function may affect the radix character used in the
conversion result. Full use
RETURN VALUES
When the string is empty or begins with an unrecognized character, +0.0
is returned as the floating-point value.
When a correct return value overflows, a properly signed HUGE_VAL (INF)
is returned. On underflow, a properly signed 0 (zero) is returned.
Upon successful completion, either function returns the converted
floating-point value.
ERRORS
If the atof() or strtod() function fails, errno may be set to the fol-
lowing value: The input string is out of range (that is, the subject
sequence can not be converted to a floating-point value without causing
underflow or overflow).
RELATED INFORMATION
Functions: atoi(3), scanf(3) delim off
atof(3)