strtod

Converts a character string to a floating-point number

double strtod (
        const char *s,
        char **endp
)

Arguments

s Pointer to a character string
endp Pointer to a storage area that will contain a pointer to the character that stopped the conversion

Return Value

The result of converting the input string pointed to by s to a double-precision value is returned. If the value exceeds the range that can be expressed, either +HUGE_VAL(1.797693134862316e+308) or -HUGE_VAL is returned according to the sign. 0 is returned if an underflow occurs.

Explanation

The character string pointed to by s is converted to a double-precision floating point number and its value is returned. The string pointed to by s must be in one of the following formats.
[ws][sn][ddd]
[ws] White space (can be omitted)
[sn] Sign (can be omitted)
[ddd] Number string (can be omitted)
strtod() stops conversion when a character is encountered that cannot be converted. A pointer to the character that terminated the conversion is placed at the storage location specified by endp unless endp is NULL.

Notes

Error processing is shown in the following table:

Condition Return value Error
Outside the range that can be expressed +/- HUGE_VAL Domain error
Underflow 0 Domain error

See Also

atof()