Math errors in python

Dan Bishop danb_83 at yahoo.com
Sun Sep 19 01:26:36 EDT 2004


Gary Herron <gherron at islandtraining.com> wrote in message news:<mailman.3482.1095528019.5135.python-list at python.org>...
> 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.

Actually, it's a feature of limited-precision floating-point in ANY
base, not just binary.  This includes base-10.  (I'm sure you've seen
BCD calculators that give 1/3*3=0.99999999.)



More information about the Python-list mailing list