Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

wcstod, wcstof, wcstold - convert wide character string to floating-point number

&pagelevel(4)&pagelevel

Syntax

#include <wchar.h>

double wcstod(const wchar_t *nptr, wchar_t **endptr);
float wcstof(const wchar_t *nptr, wchar_t **endptr);
long double wcstold(const wchar_t *nptr, wchar_t **endptr);

Description

These functions convert the initial portion of the wide character string pointed to by nptr to a double-precision representation. The input wide character string is first decomposed into three parts:

  • an initial, possibly empty, sequence of white-space wide character codes (as specified by iswspace()),
  • 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 code of the input wide character string.

wcstod() then attempts to convert the subject sequence to a floating-point number, and returns the result.

The expected form of the subject sequence may be structured as follows:

[+|-][digit...][.][digit...][{E|e}[+|-]digit...]
oder
[+|-]0{X|x}[hexdigit...][.][hexdigit...][{P|p}[+|-]digit...]

If the subject sequence has the expected form, the sequence of wide character codes starting with the first digit or the radix (whichever occurs first) is interpreted as a floating constant as defined in the C language, except that the radix is used in place of a period, and that if neither an exponent part nor a radix appears, a radix is assumed to follow the last digit in the wide character string. If the subject sequence begins with a minus sign, the value resulting from the conversion is negated. 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 radix is defined in the program's locale (category LC_NUMERIC). In the POSIX locale, or in a locale where the radix is not defined, the radix defaults to a period (.).

In a locale other than the POSIX locale, other implementation-dependent subject sequence forms may be 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.

Return val.

Converted value 



if successful.


0

if no conversion could be performed.


+/-HUGE_VAL
+/-HUGE_VALF
+/-HUGE_VALL

depending on the function type and the sign of the result, the correct value is outside the range of representable values. errno is set to indicate the error..

Errors

wcstod(), wcstof() and wcstold() will fail if: 


ERANGE

The value to be returned would cause overflow or underflow.

Notes

Since 0 is returned on error and is also a valid return value on success, an application wishing to check for error situations should perform the following actions: set errno to 0, call wcstod(), then check errno, and if it is non-zero, assume that an error has occurred.

Restriction
This version of the C runtime system only supports 1-byte characters as wide character codes. They are of type wchar_t (see stddef.h). (End) 

See also

iswspace(), localeconv(), scanf(), setlocale(), wcstol(), wchar.h.