function
<cwchar>
wcstold
long double wcstold (const wchar_t* str, wchar_t** endptr);
Convert wide string to long double
Parses the C wide string str interpreting its content as a floating point number and returns its value as a long double. If endptr is not a null pointer, the function also sets the value of endptr to point to the first character after the number.
This is the wide character equivalent of strtold (<cstdlib>), interpreting str in the same way.
Parameters
- str
- C wide string beginning with the representation of a floating-point number.
- endptr
- Reference to an already allocated object of type wchar_t*, whose value is set by the function to the next character in str after the numerical value.
This parameter can also be a null pointer, in which case it is not used.
Return Value
On success, the function returns the converted floating point number as a value of type long double.
If no valid conversion could be performed, the function returns zero (0.0L).
If the correct value is out of the range of representable values for the type, a positive or negative HUGE_VALL is returned, and errno is set to ERANGE.
If the correct value would cause underflow, the function returns a value whose magnitude is no greater than the smallest normalized positive number (some library implementations may also set errno to ERANGE in this case).
Example
1 2 3 4 5 6 7 8 9 10 11 12 13
|
/* wcstold example */
#include <wchar.h>
int main ()
{
wchar_t szOrbits[] = L"90613.305 365.24";
wchar_t * pEnd;
long double f1, f2;
f1 = wcstold (szOrbits,&pEnd);
f2 = wcstold (pEnd,NULL);
wprintf (L"Pluto takes %.2Lf years to complete an orbit.\n", f1/f2);
return 0;
}
|
Output:
Pluto takes 248.09 years to complete an orbit.
|
See also
- strtold
- Convert string to long double (function)
- wcstod
- Convert wide string to double (function)
- wcstol
- Convert wide string to long integer (function)