[Python-Dev] The Case Against Floating Point ==

Terry Reedy tjreedy at udel.edu
Thu Mar 13 22:13:13 CET 2008


"Imri Goldberg" <lorgandon at gmail.com> wrote in message 
news:47D8E3E0.7010509 at gmail.com...
| Most experienced programmers know that you shouldn't compare floating
| point numbers with ==.

As a general statement, this is wrong.  Mark gave examples.
Please drop the proposal.

The reason for the int division change is the idea that expressions 
involving integral values should, insofar as possible, have the same value 
result regardless of the types used to carry the input (or output) values. 
Hence 1/2 should equal 1.0/2.0 == .5.  The idea that 1 == 1 and 1.0 == 1.0 
should give a different answer goes against this principle and the 2.x 
project of number unification.

tjr





More information about the Python-Dev mailing list