strtod(3C) strtod(3C)
NAME
strtod, strtold, atof - convert string to double-precision
number
SYNOPSIS
#include <stdlib.h>
double strtod (const char *str, char **ptr);
long double strtold (const char *str, char **ptr);
double atof (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 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)
Errors
If the correct value would cause overflow, a value that
compares equal to _HUGE_VAL is returned (according to the sign
of the value), and errno is set to ERANGE.
If the correct value would cause underflow, zero is returned
and errno is set to ERANGE.
Copyright 1994 Novell, Inc. Page 1
strtod(3C) strtod(3C)
When the -Xt compilation options are used [see cc(1)], a value
that compares equal to _HUGE is returned instead of _HUGE_VAL.
REFERENCES
cc(1), ctype(3C), fscanf(3S), setlocale(3C), strtol(3C)
Copyright 1994 Novell, Inc. Page 2