Why 3.0/5.0 = 0.59999...

Mirco Wahab peace.is.our.profession at gmx.de
Tue May 9 04:21:27 EDT 2006


Hi Davy

> When I type 3.0/5.0, the result is 0.59999...

try:

>>> print (3.0/5.0)
0.6

> Is there some precision loss? And how to overcome it?

Make sure the result gets piped
through some floating point con-
version  (like print, %s etc.)

BTW, the 0.59999999999999998 value
is the "exact" calculated value
corresponding to your floating point
accuracy (34/2 digits).


Regards

Mirco



More information about the Python-list mailing list