Python -- floating point arithmetic

Wolfram Hinderer wolfram.hinderer at googlemail.com
Thu Jul 8 16:52:56 EDT 2010


On 8 Jul., 15:10, Ethan Furman <et... at stoneleaf.us> wrote:

> Interesting.  I knew when I posted my above comment that I was ignoring
> such situations.  I cannot comment on the code itself as I am unaware of
> the algorithm, and haven't studied numbers extensively (although I do
> find them very interesting).
>
> So while you've made your point, I believe mine still stands --
> comparing floats using == to absolute numbers is almost always a mistake.

JFTR, it works because a+b == a+b (while I don't think that a+b == b+a
holds for all a and b).

In general, I totally agree with you.



More information about the Python-list mailing list