Newsgroups: comp.lang.lisp.mcl
Path: cantaloupe.srv.cs.cmu.edu!rochester!udel-eecis!news.mathworks.com!newsfeed.internetmci.com!in3.uu.net!chronicle.mv.us.adobe.com!adobe!usenet
From: Jim Meehan <jmeehan@adobe.com>
Subject: Re: floating point rounding & truncation problems
Content-Type: text/plain; charset=us-ascii
Message-ID: <32077835.69D6@adobe.com>
Sender: usenet@adobe.com (Times USENET news)
Content-Transfer-Encoding: 7bit
Organization: Adobe Systems Incorporated
References: <ej-0108961746420001@d251-powmac9500.stanford.edu> <4tu2uo$h39@Mercury.mcs.com>
Mime-Version: 1.0
Date: Tue, 6 Aug 1996 16:52:05 GMT
X-Mailer: Mozilla 2.02 (Macintosh; I; PPC)
Lines: 12

Robert Munyer wrote:
> 
>...  You can get as many bits of accuracy as
> you want, by using rational numbers instead of floating point.
> Here is an example:
> 
>     ? (defun dec-to-rat (s)
>         "this is not ready for prime time, but you get the idea."
>         (/ (read-from-string (remove #\. s))
>            (expt 10 (- (length s) (position #\. s) 1))))

Better yet, use rational or rationalize, which are part of the language.
