DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

strtod(S)


strtod -- convert string to double-precision number

Syntax

cc . . . -lc

#include  <stdlib.h>

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

Description

The strtod function returns as a double-precision floating-point number the value represented by the character string pointed to by str. The string is scanned up to the first unrecognized character.

The strtod function recognizes an optional string of ``white-space'' characters (as defined by isspace in ctype(S)), then an optional sign, then a string of digits optionally containing a decimal point, then an optional e or E followed by an optional sign or space, followed by an integer.

If the value of ptr is not (char **)NULL, a pointer to the character terminating the scan is returned in the location pointed to by ptr. If no number can be formed, *ptr is set to str, and zero is returned. If the correct value would cause overflow, ±HUGE_VAL (as defined in <math.h>) is returned (according to the sign of the value), and errno is set to ERANGE.

If the correct value would cause underflow, zero is returned and errno is also set to ERANGE.

See also

atof(S), ctype(S), scanf(S), strtol(S)

Standards conformance

strtod is conformant with:

X/Open Portability Guide, Issue 3, 1989 ;
and ANSI X3.159-1989 Programming Language -- C .


© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003