Standards / Extensions | C or C++ | Dependencies |
---|---|---|
C/C++ DFP | both | z/OS® V1.8 |
#define __STDC_WANT_DEC_FP__
#include <wchar.h>
_Decimal32 wcstod32(const wchar_t * __restrict__ nptr,
wchar_t ** __restrict__ endptr);
_Decimal64 wcstod64(const wchar_t * __restrict__ nptr,
wchar_t ** __restrict__ endptr);
_Decimal128 wcstod128(const wchar_t * __restrict__ nptr,
wchar_t ** __restrict__ endptr);
The wcstod32() wcstod64(), and wcstod128() functions convert the initial portion of the wide-character string pointed to by nptr to _Decimal32, _Decimal64, and _Decimal128 representation, respectively.
First, they decompose the input wide-character string into three parts:
Then, they attempt to convert the subject sequence to a floating-point number, and return the result.
The expected form of the subject sequence is an optional plus or minus sign, then one of the following:
The subject sequence is defined as the longest initial subsequence of the input wide-character string, starting with the first non-white-space wide character, that is of the expected form. The subject sequence contains no wide characters if the input wide character string is not of the expected form.
If the subject sequence has the expected form for a floating-point number, the sequence of wide characters starting with the first digit or the decimal-point wide character (whichever occurs first) is interpreted as a floating constant. If neither an exponent nor a decimal-point character appears in a decimal floating point number, an exponent with value zero is assumed to follow the last digit in the string. If the subject sequence begins with a minus sign, the sequence is interpreted as negated. A wide character sequence INF or INFINITY is interpreted as an infinity. A wide character sequence NAN, NAN(),or NAN(n-char-sequence) is interpreted as a quiet NAN. A wide character sequence of NANS, NANS(),or NANS(n-char-sequence), is interpreted as a signalling NaN.
A pointer to the final wide-character string is stored in the object pointed to by endptr, provided that endptr is not a null pointer.
The converted value keeps the same precision as the input if possible, and the value may be denormalized. Otherwise, rounding may occur. Rounding happens after any negation.
In other than the "C" locale, additional locale-specific subject sequence forms are accepted.
If the subject sequence is empty or does not have the expected form, no conversion is performed; the value of nptr is stored in the object pointed to by endptr, provided that endptr is not a null pointer.
Argument | Description |
---|---|
nptr | Input pointer to start of the wide-character string to be converted |
endptr | NULL, or a pointer to a output pointer field that is filled in with the address of the first wide character in the input wide-character string that is not used in the conversion. |
The functions return the converted value, if any. If no conversion could be performed, the value +0.E0DF, +0.E0DD, or +0.E0DL is returned. If the correct value is outside the range of representable values, plus or minus HUGE_VAL_D32, HUGE_VAL_D64, or HUGE_VAL_D128 is returned (according to the return type and sign of the value), and errno is set to ERANGE. If the result underflows, the functions return a value whose magnitude is no greater than the smallest normalized positive number in the return type. No signal is raised at the point of returning a signaling NaN.
errno | Description |
---|---|
ERANGE | The input wide-character string represents a value too large to fit in the output Decimal Floating Point type. |
See wcstod() — Convert wide-character string to a double floating-point for an example.