[Ecls-list] Rounding bug in float

Juan Jose Garcia-Ripoll juanjose.garciaripoll at googlemail.com
Mon Mar 30 18:03:59 UTC 2009

On Mon, Mar 30, 2009 at 7:52 PM, Robert Dodier <robert.dodier at gmail.com> wrote:
> On Tue, Mar 24, 2009 at 10:41 PM, Raymond Toy <toy.raymond at gmail.com> wrote:
>> With ecl 8.12.0 on Linux, I get
>> (float (/ (1- (ash 1 100)) (ash 1 100)) 1d0) -> .999999...99d0
>> I think the answer should be 1d0 since the difference between 1 and the
>> rational above is far less than double-float-negative-epsilon.  Both
>> clisp and cmucl produce 1d0.
> I'm surprised the CLHS doesn't offer any guidance here.

One thing that may be causing this is that float epsilon is too small.
The value of the floating point epsilon is computed with a program and
it is well known that Intel processors provide more precision than it
is mandated by floating point standards. GMP on the other hand,
probably sticks to the 54 bits that a floating point number uses.

One solution to this would be to use GMP's mpfr class and the extended
functions mpfr_set_q and mpfr_get_d, which allow for arbitrary
precision, but that is an overkill, isn't it?


Instituto de Física Fundamental, CSIC
c/ Serrano, 113b, Madrid 28009 (Spain)

More information about the ecl-devel mailing list