home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume4
/
strtod
/
README
< prev
next >
Wrap
Text File
|
1989-02-03
|
2KB
|
45 lines
FILES:
README - this file
makefile - a trivial makefile
str2dbl.c - defines str2dbl(), requires atof() + float support
double str2dbl(char *str, char **ptr)
converts the character string str points to to a double-precision
floating-point number and returns it. str2dbl() recognises
<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 str2dbl().
{This will typically be a layout character or NUL.}
If there aren't any digits at the front (e.g. the input is
"e45" or "Fred" or "-gotcha-") str2dbl() 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") str2dbl() 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 that look like that. Spaces are not otherwise
accepted inside numbers.
If the correct value cannot be represented, str2dbl() sets errno
to ERANGE, and returns +/-HUGE for overflow, +/-ZERO for underflow.
WARNING:
The source code as provided is set up for 64-bit IEEE-754 floating
point. VAX and IBM floating-point formats are different, so the
numeric range is different. Some machines which look as though
they have IEEE floats may not support infinities or denormalised
numbers, in which case the numeric range is different. You will
have to determine the correct values for your machine.