Computing

Why 0.1 + 0.2 isn't 0.3: flip the 64 bits a computer uses for decimals

Grid of 64 coloured bits beside the title Why 0.1 + 0.2 isn't 0.3
30seconds
The 30-second version

Type 0.1 + 0.2 into almost any programming language and you get 0.30000000000000004. Nothing is broken. Computers count in powers of two, and a tenth is an endless repeating fraction in binary, so it has to be rounded to fit in 64 bits.

Flip the real bits of a double yourself and see the exact value they stand for, and learn how a rounding error this small helped cause a deadly missile failure in 1991.

Deep dive · 3 min
Deep dive · 3 min

More in Computing

View all →