Floating point subtraction rounding error (NOT display error)

Paddy paddy3118 at googlemail.com
Fri Dec 14 02:26:25 EST 2007


On Dec 14, 3:22 am, Keflavich <keflav... at gmail.com> wrote:
> On Dec 13, 5:52 pm, Steven D'Aprano <st... at REMOVE-THIS-
>
> cybersource.com.au> wrote:
> > On Thu, 13 Dec 2007 14:30:18 -0800, Keflavich wrote:
> > > Hey, I have a bit of code that died on a domain error when doing an
> > > arcsin, and apparently it's because floating point subtraction is having
> > > problems.
>
I've come to understand that
 1. Floats are fuzzy around the edges.
 2. Never do: "The difference between two floats is equal to..."
    Do: "The difference between two floats is in the range ..."
But even 2 needs some serious thinking if the range of float values
being
compared is large.

Its unscientific, but floats need more respect.

- Paddy.





More information about the Python-list mailing list