STRTOD(3C) SysV STRTOD(3C)
NAME
strtod, atof - convert string to double-precision number
SYNOPSIS
#include <stdlib.h>
double strtod (str, ptr)
const char *str;
char **ptr;
double atof (str)
const 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.
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, then an optional e or E
followed by an optional sign or space, followed by an integer.
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 zero is returned.
Except for the behavior on error, atof(str) is equivalent to
strtod(str, (char **)NULL).
SEE ALSO
ctype(3C), scanf(3S), strtol(3C).
DIAGNOSTICS
The behavior of atof is undefined if the value of the result cannot be
represented. It does not affect the value of errno.
If the correct value is outside the range of representable values, strtod
returns +HUGE_VAL (as defined in <math.h>) (according to the sign of the
value), and sets errno to ERANGE. If the correct value would cause
underflow, strtod returns zero and sets errno to ERANGE.