[gambit-list] Relaxing moment
Taylor R Campbell
campbell at mumble.net
Fri Oct 3 16:55:07 EDT 2008
Date: Fri, 3 Oct 2008 15:42:18 -0400
From: "Guillaume Cartier" <gcartier at jazzscheme.org>
For a relaxing moment using Gambit, try evaluating the following :
(inexact->exact 2.2)
----------
the 2476979795053773/1125899906842624 result shows that Gambit does indeed
smoke some powerfull stuff!
That is the exact rational value of the nearest floating-point
approximation to the number 2.2. If what you wanted was exactly the
rational number 11/5, then you can type just that, or #e2.2 to request
an exact interpretation of the decimal notation. Or, if 2.2 is the
result of some computation, and you are interested less in the
precision of the floating-point representation than in a particular
precision of your choice, then you can use the procedure RATIONALIZE
to find the simplest rational number differing from your result by no
more than a given bound:
(rationalize (inexact->exact 2.2) 1/10)
;Value: 9/4
(rationalize (inexact->exact 2.2) 1/100)
;Value: 11/5
More information about the Gambit-list
mailing list