Guardian Native C Library Calls Reference Manual (G06.28+, H06.05+)

Guardian Native C Library Calls (a - e) atof(3)
NAME
atof - Converts a character string to a double-precision
oating-point value
LIBRARY
G-series native Guardian processes: $SYSTEM.SYSnn.ZCRTLSRL
G-series native OSS processes: /G/system/sysnn/zcrtlsrl
H-series native Guardian processes: $SYSTEM.ZDLLnnn.ZCRTLDLL
H-series OSS processes: /G/system/zdllnnn/zcrtldll
SYNOPSIS
#include <stdlib.h>
double atof(
const char *nptr);
PARAMETERS
nptr Points to the character string to be converted.
DESCRIPTION
The atof() function converts the string pointed to by the nptr parameter to a double oating-
point value up to the rst character that is inconsistent with the format of a oating-point number.
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 undened.
The atof() 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
specied by the isspace() function for programs in the C/POSIX locale
and the iswspace() function for programs in other locales).
A subject sequence interpreted as a oating-point constant.
A nal string of one or more unrecognized characters, including the ter-
minating null byte of the input string.
After decomposition of the string, the subject sequence is converted to a
oating-point number, and the resulting value is returned. A subject sequence is
dened as the longest initial subsequence of the input string, starting with the
rst non-white-space character, that is of the expected form. The expected form
and order of the subject sequence is as follows:
1. An optional + (plus) or - (minus) sign.
2. A sequence of digits optionally containing a radix character.
3. An optional exponent part, consisting 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
rst non-white-space character is not a sign, a digit, or a radix character, the sub-
ject sequence contains no characters.
In the TNS environment, the atof() function supports only the C/POSIX locale.
In the native environment, all locales are supported.
The setlocale() function might affect the radix character used in the conversion
result. The radix character is controlled by the LC_NUMERIC category of the
527192-007 Hewlett-Packard Company 125