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!
Afficher les réponses par date
On Fri, Oct 03, 2008 at 01:17:37PM -0700, Ben Goetter wrote:
Guillaume Cartier wrote:
the 2476979795053773/1125899906842624 result shows that Gambit does indeed smoke some powerfull stuff!
PLT Scheme 4.1 reports identical results. FWIW.
Actually, it's even more interesting than that: Mzscheme (command-line) produces that result, but DrScheme (GUI) produces (graphically, with a properly horizontal vinculum) 2 225179981368525/1125899906842624. Even more amusingly, that (above) is how the graphical result was translated to ascii by cut-and-paste operation. Neat! (Seems like an awful lot of effort to go to to avoid frightening the kiddies...)
Cheers,
Andrew.
Guillaume Cartier wrote:
the 2476979795053773/1125899906842624 result shows that Gambit does indeed smoke some powerfull stuff!
(...sorry, keyboard glitch.) PLT Scheme 4.1 reports exactly the same result. If you're looking for the answer 11/5, try (inexact->exact #e2.2) which overrides the automatic inexact-ness of a numerical constant containing a decimal point (R5RS 6.2.4). FWIW.
Ben
Date: Fri, 3 Oct 2008 15:42:18 -0400 From: "Guillaume Cartier" gcartier@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