Rounding curiosity

PyBo someone at somewhere.com
Tue Nov 16 21:35:24 EST 2004


What is wrong with this picture:

 >>> x = 500000000.0
 >>> y = x / (1024 * 1024)
 >>> y
476.837158203125
 >>> z = round(y, 2)
 >>> z
476.83999999999997

Obviously, '476.83999999999997' is not rounded to two
decimal places. Or am I doing something wrong?



More information about the Python-list mailing list