Why 0.1 + 0.2 ≠ 0.3
Your computer stores every number in 64 switches. Most decimals do not fit, so it keeps the nearest one it has. Type a number below — or flip the switches yourself — and watch the tidy decimal you asked for turn into the long one that is actually stored.
The number
normalplain (0.1) · scientific (5e-324) · or a raw pattern (0x3FB999999999999A)
prints as
actually stored
the gap
The 64 switches
click any switch to flip itsignbit 63
exponentbits 62–52 · how big
fractionbits 51–0 · the digits
Its nearest neighbours
nothing exists in betweenThe 0.1 + 0.2 story
The one-line lesson: binary cannot write 0.1 exactly, the same way decimal cannot write one third exactly — so the machine stores the closest number it owns and quietly carries the difference forward.