guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Project: a good floating point printer/reader.


From: Marius Vollmer
Subject: Project: a good floating point printer/reader.
Date: 09 May 2002 22:17:13 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Hi,

I think we need a better floating point printer and or reader.  The
current ones can not print denormal numbers, and the string printed
will not always read back as the exact same number (as required by
R5RS).


guile> (define (t x) (= x (string->number (number->string x))))
guile> (t 0.1432987654987436)
#f
guile> (t 0.1432987654987430)
#t

(That is no special number.  I just tried a couple until t returned #f.)

guile> (/ 1e-308 2)
#.#

Also, Guile should be able to read denormal number:

guile> 1e-309
ERROR: In procedure string->number:
ERROR: Argument out of range: -309
ABORT: (out-of-range)


Good algorithms might be the ones describes in these two papers:

  Printing Floating Point Numbers Quickly and Accurately. Robert
  G. Burger and R. Kent Dybvig. ACM SIGPLAN 1996 Conference on
  Programming Language Design and Implementation, June
  1996.

  http://www.cs.indiana.edu/~dyb/FP-Printing-PLDI96.ps.gz


  William D Clinger. How to Read Floating Point Numbers Accurately. In
  Proceedings of the 1990 ACM Conference on Programming Language
  Design and Implementation, pages 92-101.

  ftp://ftp.ccs.neu.edu/pub/people/will/howtoread.ps

If anyone wants to work on this, that would be great.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]