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

Tiago A.O.A. tiagoaoa at cos.ufrj.br
Fri Mar 14 03:50:14 CET 2008


I would suggest something like a ~= b, for "approximately equal to". How 
approximately? Well, there would be a default that could be changed 
somewhere.

Don't know if it's all that useful, though.


Tiago A.O.A.

Terry Reedy escreveu:
> "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
>
>
>
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: http://mail.python.org/mailman/options/python-dev/tiagoaoa%40cos.ufrj.br
>
>   



More information about the Python-Dev mailing list