STRTOD - convert string to double precision number.

(ANSI Standard)

Usage:

#include <stdlib.h>
dx = strtod( s, p );

Where:

const char *s;
is the string to be converted into a double precision number. This string may consist of any number of blanks and/or tabs, possibly followed by a sign, followed by a string of digits that may contain a decimal point, then an "e" or "E" possibly followed by a sign, followed by an integer. It may also be in the hexadecimal format used by the "%a" format of "printf".
char **p;
points to a pointer that will be set to the character immediately following the double precision number in the string "s". For example, with
s = "1.23y";
dx = strtod(s,p);
a pointer to the character 'y' would be placed in "*p". If no floating point number can be formed from "s", "*p" points to the first character of "s". If "p" is the NULL pointer, this sort of action does not take place.
double dx;
is the double precision number obtained from "s". If no conversion could be performed (because the string didn't start with a valid number), 0.0 is returned. If there was an overflow, "strtod" sets "errno" to ERANGE and returns positive or negative HUGE_VAL (where HUGE_VAL is a large positive double value defined in <math.h>). It there was an underflow, "strtod" returns 0.0.

Description:

"strtod" converts the string "s" into a double precision number. Conversion stops with the first character that cannot be part of such a number.

Copyright © 2000, Thinkage Ltd.