home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fred Fish Collection 1.5
/
ffcollection-1-5-1992-11.iso
/
ff_disks
/
200-299
/
ff218.lzh
/
EdLib
/
man
/
StrToD
< prev
next >
Wrap
Text File
|
1989-06-04
|
2KB
|
59 lines
STRTOD(3) Library Functions STRTOD(3)
NAME
strtod - convert a string to a double precision floating point
number
SYNOPSIS
#include <edlib.h>
double strtod(str,ptr)
char *str;
char **ptr;
DESCRIPTION
Strtod converts the character string str to a double precision
floating point number and returns this value. Strtod recognises
the following in a string representing a valid double:
<space>... [+|-] <digit>... [. <digit>...] [<exponent>]
where <exponent> is
e|E [+|-| ] <digit> <digit>...
If ptr is not (char**)NULL, *ptr is assigned a pointer to the
character just after the last character accepted by strtod.
This will typically be a layout character or NUL.
If there are not any digits at the beginning of the string,
(e.g. the input is "e45" or "Fred" or "-gotcha-") strtod will
make *ptr point to the whole of str (even if there were leading
spaces and signs) and will return 0.0.
If there is some problem with the exponent (e.g. the input is
"1.2e%45") strtod will reject all of the exponent, making *ptr
point to the 'e', and will convert only the preceding characters.
A single space after the 'e' or 'E' of an exponent is accepted as
if it were a '+' sign, because some output formatting routines
generate numbers in this form. Spaces are not otherwise accepted
inside numbers.
If the correct value cannot be represented, strtod sets the
external variable errno to ERANGE, and returns +/-HUGE for
overflow, +/-ZERO for underflow.
WARNING
Strtod returns a IEEE double. If you would like to use this routine,
you must compile your code with the +fi flag to cc to use IEEE floats
instead of ffp floats.
AUTHOR
Richard A. O'Keefe, 11/03/89