wcstold(3)wcstold(3)NAMEwcstold - Convert a wide-character string to a long double-precision
value
SYNOPSIS
#include <wchar.h>
long double wcstold(
const wchar_t *ws,
wchar_t **endptr );
LIBRARY
Standard C Library (libc)
STANDARDS
Interfaces documented on this reference page conform to industry stan‐
dards as follows:
wcstold(): ISO C
Refer to the standards(5) reference page for more information about
industry standards and associated tags.
PARAMETERS
Points to the wide-character string to be converted to a long double-
precision floating-point value. Points to a pointer in which the
wcstold() function stores the position of the final wide-character seg‐
ment of the string, which contains unrecognized characters and the null
terminator.
DESCRIPTION
The wcstold() function converts the initial portion of the wide-charac‐
ter string pointed to by the ws parameter to a long double-precision
floating-point value. The input wide-character string is first broken
down into three parts: an initial (possibly empty) sequence of white-
space wide-character codes (as specified by the iswspace() function); a
subject sequence interpreted as a floating-point constant; and a final
wide-character string of one or more unrecognized wide-character codes,
including the terminating null wide character. The subject sequence is
then (if possible) converted to a floating-point number and returned as
the result of the wcstold() function.
The subject sequence is expected to consist of an optional + (plus
sign) or - (minus sign), a nonempty sequence of digits (which may con‐
tain a radix character), and an optional exponent. The exponent con‐
sists of e or E, followed by an optional sign, followed by one or more
decimal digits. The subject sequence is the longest initial subsequence
of the input wide-character string (starting with the first nonwhite-
space wide-character code) that is of the expected form. The subject
sequence contains no wide-character codes if the input wide-character
string is empty or consists entirely of white-space wide-character
codes, or if the first nonwhite-space wide-character code is other than
a sign, a digit, or a radix character.
If the subject sequence is valid, the sequence of wide-character codes,
starting with the first digit or radix character (whichever occurs
first), is interpreted as a floating-point or double-precision float‐
ing-point constant. The locale's radix character is treated as equiva‐
lent to the . (period) within floating-point constants in the C locale.
If neither an exponent or radix character appears, a radix character is
assumed to follow the last digit in the wide-character string. If the
subject sequence begins with - ( a minus sign), the conversion value is
negated. The radix character is determined by the LC_NUMERIC category
in the program's current locale. In the C locale, or in a locale where
the radix character is not defined, the radix character is a .
(period).
The wcstold() function stores a pointer to the final wide-character
segment of the string (starting with the first invalid character) in
the object pointed to by the endptr parameter, unless the endptr param‐
eter is a null pointer.
RETURN VALUES
The wcstold() function returns the converted value of a long double-
precision floating-point value if a valid floating-point constant is
found. If the converted value is outside the range of representable
values (either too high or too low), the function returns plus or minus
HUGE_VAL and sets errno to [ERANGE]. If the converted value would cause
underflow, the function returns 0 (zero) and sets errno to [ERANGE]. If
the subject sequence is empty or does not have the expected form, the
function performs no conversion and returns 0 (zero). In this case,
the value specified by the ws parameter is stored in the object pointed
to by the endptr parameter, provided that the endptr parameter is not a
null pointer.
Since the wcstold() function returns 0 (zero) or HUGE_VAL in the event
of an error and these values are also valid returns if the wcstold()
function is successful, applications should set errno to 0 (zero)
before each call to the wcstold() function and check errno after each
return from the function. If errno is nonzero after a return, an error
occurred. Additionally, if 0 (zero) is returned, applications should
check if the endptr parameter equals the nptr parameter. In this case,
there was no valid subject string.
ERRORS
If the following condition occurs, the wcstold() function sets errno to
the corresponding value: The converted value would cause underflow or,
if outside the range of representable values, overflow.
SEE ALSO
Functions: atof(3), iswspace(3), localeconv(3), scanf(3), setlocale(3),
wcstod(3), wcstol(3)
Standards: standards(5)wcstold(3)