[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ratio implementation

From: Marius Vollmer
Subject: Re: ratio implementation
Date: Tue, 14 Oct 2003 15:03:41 +0200
User-agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3 (gnu/linux)

Bill Schottstaedt <address@hidden> writes:

> I made the requested changes (using the Oct-9 CVS Guile):

With your new files, I now get

  guile> (inexact->exact 123456789123456789.0)

This might have to do with your clever continued fraction
approximation procedure.


  guile> (define pi (* 2 (acos 0)))
  guile> (- (inexact->exact pi) pi)

Shouldn't we be able to do better than this?  Double precision is good
to about 2e-16 and I would expect the fraction returned from
inexact->exact to be accurate within that margin.  (I don't know
inexact->really why I expect this, it just seems to make sense.)

What about this approach: find the integer correspondig to the bits of
the mantissa of the double number (a bignum) and then correct for the
scaling and the exponent either by multiplying with a power of two, or
building a fraction with that power of two.

I don't have the details ready yet, but I think I'll try to come up
with code for this... (when it isn't already in GMP).

reply via email to

[Prev in Thread] Current Thread [Next in Thread]