Why Binary Cannot Accurately Represent Decimal 0.1

Certain decimal fractions like 0.1 cannot be represented with finite precision in the standard binary number system because of how number bases handle fractional values. Just as the fraction 1/3 produces an infinitely repeating sequence in decimal notation (0.3333…), the fraction 1/10 produces an infinite repeating sequence in binary (0.000110011…). Because computers must store numbers using a fixed amount of memory, they cannot store an infinite sequence and must truncate or round the value, leading to unavoidable precision limits in standard binary floating-point representation.

Whether a fraction terminates in a given number system depends on the prime factors of that system’s base. In the base-10 (decimal) system, the base is 10, which has the prime factors 2 and 5. Any simplified fraction whose denominator contains only prime factors of 2 and 5 (such as 1/2, 1/4, 1/5, or 1/10) can be written as a finite decimal. If a denominator contains any other prime factor, like 3 or 7, the decimal representation repeats infinitely.

In the base-2 (binary) system, the base is 2, which has only a single prime factor: 2. Consequently, the only fractions that can terminate in binary are those whose denominators, in reduced form, are powers of 2 (such as 1/2, 1/4, 1/8, 1/16, and so on).

The decimal number 0.1 is equivalent to the fraction 1/10. When reduced, the denominator is 10, which is composed of the prime factors 2 and 5. Because 5 is not a factor of the binary base, dividing 1 by 10 in binary yields the infinitely repeating fraction:

0.00011001100110011...

Standard computer architectures implement numbers using fixed-size formats, most commonly the IEEE 754 floating-point standard. A 64-bit double-precision float allocates 53 bits to store the significant digits of a number. When the infinite binary expansion of 0.1 is forced into these 53 bits, the computer rounds the pattern, effectively storing a value equal to approximately 0.100000000000000005551115123126 in decimal. This fundamental mathematical mismatch is why simple operations like 0.1 + 0.2 often yield 0.30000000000000004 rather than exactly 0.3 in modern programming languages.