home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume4 / strtod / README < prev    next >
Text File  |  1989-02-03  |  2KB  |  45 lines

  1. FILES:
  2.     README        - this file
  3.     makefile    - a trivial makefile
  4.     str2dbl.c    - defines str2dbl(), requires atof() + float support
  5.  
  6. double str2dbl(char *str, char **ptr)
  7.     converts the character string str points to to a double-precision
  8.     floating-point number and returns it.  str2dbl() recognises
  9.  
  10.     <space>... [+|-] <digit>... [. <digit>...] [<exponent>]
  11.  
  12.     where <exponent> is
  13.  
  14.     e|E [+|-| ] <digit> <digit>...
  15.  
  16.     If ptr is not (char**)NULL, *ptr is assigned a pointer to the
  17.     character just after the last character accepted by str2dbl().
  18.     {This will typically be a layout character or NUL.}
  19.  
  20.     If there aren't any digits at the front (e.g. the input is
  21.     "e45" or "Fred" or "-gotcha-") str2dbl() will make *ptr point
  22.     to the whole of str (even if there were leading spaces and signs)
  23.     and will return 0.0.
  24.  
  25.     If there is some problem with the exponent (e.g. the input is
  26.     "1.2e%45") str2dbl() will reject all of the exponent, making *ptr
  27.     point to the 'e', and will convert only the preceding characters.
  28.  
  29.     A single space after the 'e' or 'E' of an exponent is accepted as
  30.     if it were a '+' sign, because some output formatting routines
  31.     generate numbers that look like that.  Spaces are not otherwise
  32.     accepted inside numbers.
  33.  
  34.     If the correct value cannot be represented, str2dbl() sets errno
  35.     to ERANGE, and returns +/-HUGE for overflow, +/-ZERO for underflow.
  36.  
  37. WARNING:
  38.     The source code as provided is set up for 64-bit IEEE-754 floating
  39.     point.  VAX and IBM floating-point formats are different, so the
  40.     numeric range is different.  Some machines which look as though
  41.     they have IEEE floats may not support infinities or denormalised
  42.     numbers, in which case the numeric range is different.  You will
  43.     have to determine the correct values for your machine.
  44.  
  45.