Math errors in python

Chris S. chrisks at NOSPAM.udel.edu
Sun Sep 19 09:18:06 CEST 2004


Jeremy Bowers wrote:

> On Sat, 18 Sep 2004 16:50:16 +0000, 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:
> 
> 
> Specifically (building on DogWalker's reply),
> http://www.python.org/doc/faq/general.html#why-are-floating-point-calculations-so-inaccurate
> 

Perhaps there's a simple explanation for this, but why do we go to the 
trouble of computing fractions when our hardware can't handle the 
result? If the decimal value of 1/3 is can't be represented in binary, 
then don't. We should use an internal representation that stores the 
numerator and denominator as separate integers.



More information about the Python-list mailing list