Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ nl_strtod(3C) — HP-UX 9.10

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

ctype(3C)

setlocale(3C)

scanf(3S)

strtol(3C)

hpnls(5)

lang(5)

strtod(3C)

NAME

strtod, atof, nl_strtod, nl_atof − convert string to double-precision number

SYNOPSIS

#include <stdlib.h>

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

double atof(const char *str);

double nl_strtod(const char *str, char **ptr, int langid);

double nl_atof(const char *str, int langid);

DESCRIPTION

strtod() returns, as a double-precision floating-point number, the value represented by the character string pointed to by str. The string is scanned (leading white-space characters as defined by isspace() in ctype(3C) are ignored) up to the first unrecognized character. If no conversion can take place, zero is returned.

strtod() recognizes characters in the following sequence:

1.  An optional string of “white-space” characters which are ignored,

2.  An optional sign,

3.  A string of digits optionally containing a radix character,

4.  An optional e or E followed by an optional sign or space, followed by an integer. 

The radix character is determined by the loaded NLS environment (see setlocale(3C)). If setlocale() has not been called successfully, the default NLS environment, "C", is used (see lang(5)). The default environment specifies a period (.) as the radix character.

If the value of ptr is not (char **)NULL , the variable to which it points is set to point at the character after the last number, if any, that was recognized.  If no number can be formed, ∗ptr is set to str, and zero is returned.

atof(str) is equivalent to strtod (str, (char **)NULL). 

nl_strtod() and nl_atof() are similar to the above routines, but first call langinit() (see nl_init(3C)) to load the NLS environment specified by langid. 

EXTERNAL INFLUENCES

Locale

The LC_NUMERIC category determines the value of the radix character within the currently loaded NLS environment. 

RETURN VALUE

If the correct value would cause overflow, +HUGE_VAL or -HUGE_VAL 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 set to ERANGE. 

WARNINGS

nl_strtod() and nl_atof() are provided for historical reasons only.  Their use is not recommended.  Use strtod() and atof() instead. 

AUTHOR

strtod() was developed by AT&T and HP. 

SEE ALSO

ctype(3C), setlocale(3C), scanf(3S), strtol(3C), hpnls(5), lang(5). 

STANDARDS CONFORMANCE

strtod(): AES, SVID2, XPG2, XPG3, XPG4, ANSI C

atof(): AES, SVID2, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C

Hewlett-Packard Company  —  HP-UX Release 9.10: April 1995

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026