strange behaviour with simple decimals



On Sat, 2007-04-14 at 07:42 -0500, Barton Willis wrote:
> Some of you might be amused by:
> 
> (%i1) d(x) := cf(rationalize(x))$
> 
> (%i2) d(0.2^2 - 0.04);
> (%o2) [0,144115188075855872]
> (%i3) factor(%);
> (%o3) [0,2^57]
> 
> (%i4) d(1.3^2);
> (%o4) [1,1,2,4,2,2,1,592578898337,1,1,18,2]

Well I find this validating anyway.  I wrote a continued fraction
package in Scheme for my own amusement.  I tried your examples and got
identical results in both cases.  My function "inexact->fscf"
rationalizes a float using the Scheme built-in function "exact->inexact"
and applies a function that computes the simple continued fraction of a
rational to the result.  Here's a transcript (I'm using MzScheme version
300):

    > (require "fscf.scm")
    > (inexact->fscf (- (* 0.2 0.2) 0.04))
    (0 144115188075855872)
    > (expt 2 57)
    144115188075855872
    > (inexact->fscf (* 1.3 1.3))
    (1 1 2 4 2 2 1 592578898337 1 1 18 2)

 -- Bill Wood