[Openmcl-devel] Double precision Floor bug?

Scott L. Burson Scott at sympoiesis.com
Mon Jun 4 21:29:22 PDT 2012


On Sun, Jun 3, 2012 at 3:44 PM, Brian Hayes <bhayes at amsci.org> wrote:
>
> This isn't really a Lisp issue; it's an IEEE-754 floating-point issue.

I'm not sure it's quite that simple.  Yes, FP arithmetic is
approximate and produces results that are sometimes counterintuitive.
But the lesson there is precisely that subtle changes to FP arithmetic
_can_ produce more desirable results.

In the case before us, it seems entirely possible that the second
implementation of FLOOR has better properties in all or most cases
than the first.  I haven't analyzed it sufficiently to convince myself
of that, but I agree that its behavior on the given example is closer
to what I would want.  (As Sudhir points out, one would naively expect
the remainder always to be less than the divisor.)

I'd wager a little digging would turn up a text on FP algorithms that
would answer the question authoritatively.

-- Scott



More information about the Openmcl-devel mailing list