Rounding issue when adding floats in python, is this normal?
Posted
by thepearson
on Stack Overflow
See other posts from Stack Overflow
or by thepearson
Published on 2010-05-06T23:13:18Z
Indexed on
2010/05/06
23:18 UTC
Read the original article
Hit count: 194
I just wanted to know if this behavior is expected. If so, can someone explain to me why. This has probably been answered elsewhere I can't seem to find it using Google. Probably not searching with the right terms. I am running Ubuntu 10.04.
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> var = 10.0
>>> var
10.0
>>> var + 5
15.0
>>> var + 5.1
15.1
>>> var + 5.2
15.199999999999999
>>>
© Stack Overflow or respective owner