Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ strtod(3) — AIX PS/2 1.2.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

scanf, fscanf, sscanf, NLscanf, NLfscanf, NLsscanf, wsscanf

strtol, atol, atoi



STRTOD(3,L)                 AIX Technical Reference                 STRTOD(3,L)



-------------------------------------------------------------------------------
strtod, atof



PURPOSE

Converts an ASCII string to a floating-point number.

LIBRARY

Standard C Library (libc.a)

SYNTAX



                double strtod (nptr, ptr)   double atof (nptr)
                char *nptr, **ptr;          char *nptr;



DESCRIPTION

The strtod and atof subroutines convert a character string, pointed to by the
nptr parameter, to a double-precision floating-point number.  The first
unrecognized character ends the conversion.

These subroutines recognize a character string when the characters appear in
the following order:

  1. An optional string of white-space characters
  2. An optional sign
  3. A string of digits optionally containing a decimal point
  4. An optional e or E followed by an optionally signed integer.

This is represented symbolically as:

  {<sp>} [+|-] {<digit>} [.{digit}] [ (e|E) [+|-] {digit}]

where:

"<sp>" = whitespace "<digit>" = 0-9 "[ ]" = 0 or 1 "{ }" = 0 or more

If the string begins with an unrecognized character, strtod and atof return the
value 0.

If the value of ptr is not (char **) NULL, then a pointer to the character that
terminated the scan is stored in *ptr.  If an integer cannot be formed, *ptr is
set to nptr, and 0 is returned.





Processed November 7, 1990        STRTOD(3,L)                                 1





STRTOD(3,L)                 AIX Technical Reference                 STRTOD(3,L)



If the correct return value overflows, strtod and atof return INF on AIX PS/2
and 0 on AIX/370.  On underflow, strtod and atof return 0.

The atof (nptr) subroutine call is equivalent to strtod (nptr, (char **) NULL).

The strtod and atof subroutines perform conversions to a floating-point number.
See "strtol, atol, atoi" for information on conversions to integers.

ERROR CONDITIONS

The strtod subroutine fails if the following is true:

ERANGE    The value to be returned would have caused overflow or underflow.

The atof subroutine may fail if the following is true:

ERANGE    The correct value of the result would cause overflow or underflow.

RELATED INFORMATION

In this book:  "scanf, fscanf, sscanf, NLscanf, NLfscanf, NLsscanf, wsscanf"
and "strtol, atol, atoi."

































Processed November 7, 1990        STRTOD(3,L)                                 2



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