Question about floating point

Frank Millman frank at chagford.com
Tue Aug 28 10:11:35 EDT 2018


Hi all

I know about this gotcha -

>>> x = 1.1 + 2.2
>>> x
3.3000000000000003

According to the docs, the reason is that "numbers like 1.1 and 2.2 do not 
have exact representations in binary floating point."

So when I do this -

>>> y = 3.3
>>> y
3.3

what exactly is happening? What is 'y' at this point?

Or if I do this -

>>> z = (1.1 + 2.2) * 10 / 10
>>> z
3.3

What makes it different from the first example?

Thanks

Frank Millman






More information about the Python-list mailing list