123.3 + 0.1 is 123.3999999999 ?

A Puzzled User kendear_nospam at nospam.com
Thu May 15 12:14:13 EDT 2003


In Python 2.2.2

 >>> float("123.4")+0.1
123.5

 >>> float("123.3")+0.1
123.39999999999999

 >>> float("123.1") + 1
124.09999999999999

how come there are these inaccuracies?


--------------------------------
P.S.
I just tried in Perl

   print eval("123.3") + 0.1;

and it gives
123.4





More information about the Python-list mailing list