Math errors in python

Chris S. chrisks at NOSPAM.udel.edu
Sun Sep 19 03:05:50 EDT 2004


Gary Herron wrote:

> On Saturday 18 September 2004 09:50 am, Radioactive Man wrote:
> 
>>In python 2.3 (IDLE 1.0.3) running under windows 95, I get the
>>following types of errors whenever I do simple arithmetic:
>>
>>1st example:
>>
>>>>>12.10 + 8.30
>>
>>20.399999999999999
> 
> 
> 
> It's not a bug, it's a feature of binary arithmetic on ALL coumputers
> in ALL languages.  (But perhaps Python is the first time it has not
> been hidden from you.)
> 
> See the Python FAQ entry 1.4.2:
> 
> http://www.python.org/doc/faq/general.html#why-are-floating-point-calculations-so-inaccurate

That's nonsense. My 7-year old TI-83 performs that calculation just 
fine, and you're telling me, in this day and age, that Python running on 
a modern 32-bit processor can't even compute simple decimals accurately? 
Don't defend bad code.



More information about the Python-list mailing list