Why does Python report 0.1 + 0.2 == 0.3 as false?

0.1 has no exact binary form, so it is stored as a close approximation.

Start playing free

  1. A bug in the processor
  2. The language rounds to 2 places
  3. 0.1 cannot be stored exactly in binary ✔

Why: Computers store floats as binary fractions. Just like 1/3 never ends in decimal, 1/10 never ends in binary. The tiny rounding errors in 0.1 and 0.2 add up, so the sum is 0.30000000000000004.

Huh, didn't know that: Python's docs note this is not a Python bug: the same thing happens in every language that uses your hardware's floating point.

The dad joke
Why did 0.1 and 0.2 break up? They just didn't add up.
Like this card?
Play the game

References

Answer: 0.1 cannot be stored exactly in binary. Computers store floats as binary fractions. Just like 1/3 never ends in decimal, 1/10 never ends in binary. The tiny rounding errors in 0.1 and 0.2 add up, so the sum is 0.30000000000000004.

  1. Python docs: Floating-Point Arithmetic, Issues and Limitations docs.python.org/3/tutorial/floatingpoint.html
    no matter how many base 2 digits you're willing to use, the decimal value 0.1 cannot be represented exactly as a base 2 fraction
    Checked 2026-10-10.

Think this answer is wrong? Tap "Challenge this answer" on the card in the game and tell us why.

Test yourself in the game