
Type this into a browser console (F12 → Console):
0.1 + 0.2 // 0.30000000000000004
0.1 + 0.2 === 0.3 // false
Python prints the same. It looks like a bug, but it is how almost every computer stores decimals.
The reason: binary fractions
In decimal, 1/3 cannot be written exactly — it is 0.3333… forever. In binary (base 2), the same thing happens to 0.1: it becomes an endless repeating pattern. Computers store numbers in a fixed number of bits (the IEEE 754 “double” format, about 15–17 significant digits), so 0.1 is stored as the nearest possible value, very slightly off. Add two slightly-off numbers and the tiny error becomes visible.
What Excel does
Excel uses the same double format but displays at most 15 significant digits, so =0.1+0.2 shows 0.3. The error is still there:
=0.1+0.2-0.3 → 5.55112E-17 (not 0)
=1-0.9-0.1 → -2.77556E-17
That is why a reconciliation that “should be zero” sometimes shows -0.00, or a lookup on a calculated value fails.
How to avoid the bugs
- Round money at the right step:
=ROUND(A2*B2, 2)before comparing or summing. - Compare with a tolerance:
=ABS(A2-B2) < 0.005instead of=A2=B2. - In code, use decimal types for money: Python
decimal.Decimal("0.1"), or store paise/cents as whole numbers. - Do not use “Set precision as displayed” in Excel options unless you understand it — it permanently changes stored values.
More surprising computer facts in the Wacky Facts collection.