Subject: Re: parse-float trial implementation (was Re: String to real)
From: Erik Naggum <erik@naggum.no>
Date: 2000/06/09
Newsgroups: comp.lang.lisp
Message-ID: <3169560072007578@naggum.no>

* Russell Senior <seniorr@aracnet.com>
| It would be interesting and educational for me if you could point a
| few of them out.  Given the `slew' it should not be difficult.

  The last sentence is completely bogus, and obviously so.  Finding
  which of 2^64 bit patterns are read and printed wrong is no small
  task, even if there are 2^16 of them.  I spent a few hundred CPU
  hours on 2 × 600MHz Pentium III's and 2 × 400MHz Pentium II's
  stress-testing Allegro CL's floating-point reader and printer and
  came up with a few interesting cases where it missed, due to
  accumulated rounding errors.  It dook Duane Rettig of Franz Inc
  several days to come up with a solution, and it was not trivial,
  neither in terms of the code required or the time required to read
  or print floating-point numbers correctly.

  C's atof and printf were never meant to be print-read-consistent, so
  it's fairly easy to find situations where a number printed and read
  back yields a different bit pattern that is really hard to detect if
  you don't look at the bits (except for the trivial unequality), but
  for a Common Lisp system, that is basically unforgiveable.

  If you're not an expert at numerical analysis, the simple dictum is:
  don't presume to know how to read or print floating point numbers
  but do show respect for those who are experts and do know how.  (I
  fall in the latter category, not the former of these, which is why I
  keep stressing that a correct parse-float function that maintains
  print-read consistency is heavily implementation-dependent and you
  shoult not mix third-party readers with builtin printers, unless you
  know what you're doing extremely well.)

#:Erik
-- 
  If this is not what you expected, please alter your expectations.