[Prev][Next][Index][Thread]
Re: Floats and Strings
-
To: info-dylan@ai.mit.edu
-
Subject: Re: Floats and Strings
-
From: ywvcg0zd7p6bi001@sneakemail.com (Tim Olson)
-
Date: Sat, 5 May 2001 10:15:01 -0400 (EDT)
-
Organization: none
-
References: <200105050915.FAA22278@life.ai.mit.edu>
-
Xref: traf.lcs.mit.edu comp.lang.dylan:13249
In article <200105050915.FAA22278@life.ai.mit.edu>, Rob Myers
<robmyers@mac.com> wrote:
| I've added code for float-to-string and an unofficial (non-standard)
| string-to-float into gd/src/common/common-dylan/extentions.dylan.
| It's not amazingly elegant code but it works. :-)
I don't know if you already looked at this or not, but if you want a
really good float-to-string algorithm, see:
http://citeseer.nj.nec.com/28233.html
"Printing Floating Point Numbers Quickly and Accurately" by Burger and Dybvig.
This algorithm generates the shortest, correctly rounded output string
that converts to the same number when read back in. It is used in many
Scheme and Lisp implementations, and I used it as the basis for the Squeak
Smalltalk Float printing method.
If you use double-precision float values in the implementation, rather
than the unlimited precision integers, it will run much faster, and only
lose about 3 ulps (Unit of Least Precision) of accuracy.
--
-- Tim Olson