wcstod(3) Library Functions Manual wcstod(3)
NAME
wcstod - Converts a wide-character string to a double-precision value
LIBRARY
Standard C Library (libc)
SYNOPSIS
#include <wchar.h>
double wcstod ( const wchar_t *ws, wchar_t **endptr);
STANDARDS
Interfaces documented on this reference page conform to industry standards as follows:
wcstod(): XSH5.0
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 double-precision floating-point value. Points to a pointer in which the wcstod()
function stores the position of the final wide-character segment of the string, which contains unrecognized characters and the null termi-
nator.
DESCRIPTION
The wcstod() function converts the initial portion of the wide-character string pointed to by the ws parameter to a double-precision float-
ing-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 wcstod() 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 consists 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 non-
white-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 floating-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 charac-
ter 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 wcstod() 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 parameter is a null pointer.
RETURN VALUES
The wcstod() function returns the converted value of a 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 wcstod() function returns 0 (zero) or HUGE_VAL in the event of an error and these values are also valid returns if the wcstod()
function is successful, applications should set errno to 0 (zero) before each call to the wcstod() 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 wcstod() function sets errno to the corresponding value: The converted value would cause underflow
or, if outside the range of representable values, overflow.
RELATED INFORMATION
Functions: atof(3), iswspace(3), localeconv(3), scanf(3), setlocale(3), wcstol(3)
Standards: standards(5) delim off
wcstod(3)