Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ wcstod(3) — OSF/1 3.0 αXP

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

atof(3)

iswspace(3)

localeconv(3)

scanf(3)

setlocale(3)

wcstol(3)

wcstod(3)  —  Subroutines

NAME

wcstod − Converts a wide character string to a double-precision value

LIBRARY

Standard C Library (libc.a)

SYNOPSIS

#include <wchar.h> double wcstod (
const wchar_t ∗ ws,
wchar_t ∗∗endptr);

PARAMETERS

wsPoints to the wide-character string to be converted to double-precision floating-point value. 

endptrPoints to a pointer in which the wcstod() function stores the position of the final wide-character segment of the string, which contains unrecognized characters. 

DESCRIPTION

The wcstod() function converts the initial portion of the wide-character string pointed to by the ws parameter to a 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 wcstod() function. 

The subject sequence is expected to consist of an optional + (plus sign) or - (minus sign), a nonempty sequence of digits (which may contain 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 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, floating-point constant. The locale’s radix character is treated as equivalent 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 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 defaults to 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 double-precision, floating-point value, if a valid floating-point constant is found. If no conversion could be performed, a value of 0 (zero) is returned. If the converted value is outside the range (either too high or too low), the variable errno is set to [ERANGE]. In case of overflow, plus or minus HUGE_VAL is returned.  In the case of underflow, a value of zero is returned. If the subject sequence is empty or does not have the expected form, no conversion is performed. 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 calling the wcstod() function, and check errno after return from the function.  If errno is nonzero, 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 any of the following conditions occurs, the wcstod() function sets errno to the corresponding value. 

[ERANGE]The converted value is outside the range of representable values. 

RELATED INFORMATION

Functions: atof(3), iswspace(3), localeconv(3), scanf(3), setlocale(3), wcstol(3). 

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026