On 09/05/2011 10:57 PM, xyz wrote:
hi all:

As we know ,  1.1 * 1.1 is 1.21 .
But in python ,I got following :

1.1 * 1.1
1.2100000000000002

why python get wrong result? Who can tell me  where's the 0.0000000000000002 
from?

It's not a python error It's the nature of floating point arithmetic to be inaccurate on *ANY* computer. Python just allows you to see the inaccuracies.

(But try:
  print 1.1*1.1
and see that the print statement does hide the roundoff error from you.)

Read this for more info:
http://pyfaq.infogami.com/why-are-floating-point-calculations-so-inaccurate

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to