Everyday computer scienceLesson 011 min
Why does your computer think 0.1 + 0.2 is not 0.3?
Computers store decimals in sixty-four bits, and in binary one tenth never ends, so the computer keeps the closest value that fits. In most programming languages, 0.1 plus 0.2 then gives 0.3, fifteen zeros, then a 4, because the tiny errors show up at the end. This is not a bug. It is why two decimals should not be tested for an exact match.
Remember
Do not test two decimals for an exact match.
