Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

scanf(3V)

string_to_decimal(3)

STRTOD(3)  —  C LIBRARY FUNCTIONS

NAME

strtod, atof − convert string to double-precision number

SYNOPSIS

double strtod(str, ptr)
char ∗str, ∗∗ptr;

double atof(str)
char ∗str;

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 up to the first unrecognized character, using string_to_decimal(3), with fortran_conventions set to 0. 

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 for historical compatibility, 0.0 is returned, although a NaN would better match the IEEE Floating-Point Standard’s intent. 

The radix character is defined by the program’s locale (category LC_NUMERIC).  In the "C" locale, or in a locale where the radix character is not defined.  the radix character defaults to a period ‘.’. 

atof(str) is equivalent to strtod(str, (char ∗∗)NULL).  Thus, when atof(str) returns 0.0 there is no way to determine whether str contained a valid numerical string representing 0.0 or an invalid numerical string. 

SEE ALSO

scanf(3V), string_to_decimal(3)

DIAGNOSTICS

Exponent overflow and underflow produce the results specified by the IEEE Standard.  In addition, errno is set to ERANGE. 

Sun Release 4.1  —  Last change: 5 October 1989

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