3 Aug 2008 01:24
Re: rationalize returns inexact results.
Neil Jerram <neiljerram <at> googlemail.com>
2008-08-02 23:24:12 GMT
2008-08-02 23:24:12 GMT
2008/7/26 Anye Li <li.anye.0 <at> gmail.com>:
> Even if it is not a bug that rationalize returns inexact results (surprising
> and useless as they may be to me), I believe it is still a bug that (help
> rationalize) says "Return an exact number..." when in fact it does not.
Agreed. I'm just fixing this now, to make (help rationalize) say the
same as the Guile manual says:
Returns the <at> emph{simplest} rational number differing
from <at> var{x} by no more than <at> var{eps}.
As required by <at> acronym{R5RS}, <at> code{rationalize} only returns an
exact result when both its arguments are exact. Thus, you might need
to use <at> code{inexact->exact} on the arguments.
<at> lisp
(rationalize (inexact->exact 1.2) 1/100)
<at> result{} 6/5
Regards,
Neil
RSS Feed