Open System Services Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)

strtod(3) OSS Library Calls Reference Manual
For IEEE floating-point values and H-series RVUs and G06.27 and later G-series RVUs
only, one of INF, INFINITY, NAN, or NAN(seq), where seq is a sequence of digit and
nondigit characters.
When the input string is empty or consists entirely of white space, or when the first non-white-
space character is not a sign, a digit, or a radix character, the subject sequence contains no char-
acters.
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.
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 setlocale( ) function.
NOTES
In the TNS environment, the strtod( ) function supports only the C/POSIX locale. In the native
environment, all locales are supported.
This function supports both IEEE Std 754-1985 floating-point and Tandem floating-point values
in the native environment. If the value is in IEEE floating-point format, the sign of 0.0 (zero) can
be either positive or negative.
Refer to the fp_class(3) reference page for a description of IEEE value classes.
Guardian functions are available to convert between floating-point formats. Refer to the Guar-
dian Programmer’s Guide for a discussion of floating-point conversions.
RETURN VALUES
When the string pointed to by nptr is empty or begins with an unrecognized character, 0.0 (zero)
is returned as the floating-point value.
When a correct return value would cause overflow, a properly signed HUGE_VAL (INF)is
returned. On underflow, a properly signed 0.0 (zero) is returned.
Upon successful completion, the strtod( ) function returns the converted floating-point value.
Because a return value of 0.0 (zero) can represent either a valid conversion or an error, you
should use errno to check for possible errors. Set errno to a value of 0 before the call to the
strtod( ) function and then check it for a nonzero value after the call. If errno is nonzero, an
error has occurred.
ERRORS
If any of the following conditions occurs, the strtod( ) function sets errno to the corresponding
value:
[ERANGE] The input string is out of range (that is, the subject sequence cannot be converted
to a floating-point value without causing underflow or overflow).
RELATED INFORMATION
Functions: atof(3), atoi(3), fp_class(3), isnan(3), isspace(3), iswspace(3), scanf(3), setlocale(3).
STANDARDS CONFORMANCE
This function conforms to the XPG4 Version 2 specification when used for IEEE floating-point
format data.
6174 Hewlett-Packard Company 527187-017