strtof(), strtod(), strtold(), strtof_l(), strtod_l(), strtold_l()

convert string to various floating point value 

Function


SYNOPSIS

#include <stdlib.h>

float strtof(const char *nptr, char **endptr);

double strtod(const char *nptr, char **endptr);

long double strtold(const char *nptr, char **endptr);

float strtof_l(const char *nptr, char **endptr, locale_t locale);

double strtod_l(const char *nptr, char **endptr, locale_t locale);

long double strtold_l(const char *nptr, char **endptr, locale_t locale);


DESCRIPTION

The strtod() class of functions converts the string pointed by nptr to double representation. This function recognizes (in order) an optional string of spaces, an optional sign, a string of digits optionally containing a radix character, an optional 'e' or 'E', and then an optionally signed integer. The first unrecognized character ends the string. A pointer to this unrecognized character is stored in the object addressed by endptr, if endptr is not NULL.

The radix character for strtod() is that defined by the last successful call to setlocale(), category LC_NUMERIC. If setlocale(), category LC_NUMERIC, has not been called successfully, or if the radix is not defined for a supported language, the radix character is defined as a period (.).

The strtod_l() class of functions behave in the same way as strtod() class of functions without the _l suffix, but uses the specified locale rather than the global or per-thread locale. A locale_t is returned by newlocale().


PARAMETERS

nptr 

Points to a character string for strtod() class of functions to convert.

endptr 

Is a result parameter that, if not NULL, is loaded with the address of the first character that strtod() class of functions do not attempt to convert.

locale

Is a locale_t perhaps returned by newlocale() or LC_GLOBAL_LOCALE or 0 for the current thread locale set with uselocale().


RETURN VALUES

The strtod() and strtod_l() classes of functions return the converted value, if there is any. If no conversion could be performed, strtod() returns zero. If the correct value is outside the range of representable values (plus or minus), these functins return returns HUGE_VAL (or HUGE_VALF or HUGE_VALL) (according to the sign of the value) and sets errno to ERANGE. If the correct value causes underflow, strtod() and strtod_l() classes of functions return zero and sets errno to ERANGE.


CONFORMANCE

strtod() conform to ANSI/ISO 9899-1990.


MULTITHREAD SAFETY LEVEL

MT-Safe, with exceptions.

The function strtod() class of functions is MT-Safe as long as no thread calls setlocale() while this function is executing.

The function strtod_l() class of functions is MT-Safe as long as no thread calls freelocale() on locale while this function is executing.


PORTING ISSUES

None.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
atof(), newlocale(), setlocale(), strtoimax(), strtoimax_l(), strtol(), strtol_l(), strtoll(), strtoll_l(), strtoq(), strtoul(), strtoul_l(), strtoull(), strtoull_l(), strtoumax(), strtoumax_l(), strtouq()


PTC MKS Toolkit 10.4 Documentation Build 39.