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

Leszek Dubiel leszek at dubiel.pl
Thu Mar 13 17:35:03 CET 2008


>>     My suggestion is to do either of the following:
>>     1. Change floating point == to behave like a valid floating point
>>     comparison. That means using precision and some error measure
>>     
There are two ways:

1. python users have to know, that representation of float has some 
problems

2. python users must not care about internal float representation

Solution "2." is not good, because someday somebody will complain, that 
computer calculations are not accurate (some scientist who was not 
willing about learning how computer stores floats).

It is better to choose "1." -- beginers will have to accept that 
computer is not able to store every real number, because floats are 
stored as binary numbers. Maybe operator "==" for floats should be 
deprecated, and people should use something like "!~" or "=~", and they 
should be able to set precission for float numbers?






More information about the Python-ideas mailing list