Function
GLibascii_strtod
Declaration [src]
gdouble
g_ascii_strtod (
const gchar* nptr,
gchar** endptr
)
Description [src]
Converts a string to a floating point value.
This function behaves like the standard strtod()
function
does in the C locale. It does this without actually changing
the current locale, since that would not be thread-safe.
A limitation of the implementation is that this function
will still accept localized versions of infinities and NANs.
This function is typically used when reading configuration
files or other non-user input that should be locale independent.
To handle input from the user you should normally use the
locale-sensitive system strtod()
function.
To convert from a gdouble to a string in a locale-insensitive
way, use g_ascii_dtostr()
.
If the correct value would cause overflow, plus or minus HUGE_VAL
is returned (according to the sign of the value), and ERANGE
is
stored in errno
. If the correct value would cause underflow,
zero is returned and ERANGE
is stored in errno
.
This function resets errno
before calling strtod()
so that
you can reliably detect overflow and underflow.
Parameters
nptr
-
Type:
const gchar*
The string to convert to a numeric value.
The data is owned by the caller of the function. The value is a NUL terminated UTF-8 string. endptr
-
Type:
gchar**
If non-
NULL
, it returns the character after the last character used in the conversion.The argument will be set by the function. The argument can be NULL
.The returned data is owned by the function. The value is a NUL terminated UTF-8 string.