Fractions in Binary
Fractions in binary only terminate if the denominator has 2 as the only prime factor. As a result, 1/10 does not have a finite binary representation, and this causes 10 × 0.1 not to be precisely equal to 1 in floating point arithmetic. As an example, to interpret the binary expression for 1/3 = .010101..., this means: 1/3 = 0 × 2−1 + 1 × 2−2 + 0 × 2−3 + 1 × 2−4 + ... = 0.3125 + ... An exact value cannot be found with a sum of a finite number of inverse powers of two, and zeros and ones alternate forever.
Fraction | Decimal | Binary | Fractional Approx. |
---|---|---|---|
1/1 | 1 or 0.999... | 1 or 0.111... | 1/2+1/4+1/8... |
1/2 | 0.5 or 0.4999... | 0.1 or 0.0111... | 1/4+1/8+1/16... |
1/3 | 0.333... | 0.010101... | 1/4+1/16+1/64... |
1/4 | 0.25 or 0.24999... | 0.01 or 0.00111... | 1/8+1/16+1/32... |
1/5 | 0.2 or 0.1999... | 0.00110011... | 1/8+1/16+1/128... |
1/6 | 0.1666... | 0.0010101... | 1/8+1/32+1/128... |
1/7 | 0.142857142857... | 0.001001... | 1/8+1/64+1/512... |
1/8 | 0.125 or 0.124999... | 0.001 or 0.000111... | 1/16+1/32+1/64... |
1/9 | 0.111... | 0.000111000111... | 1/16+1/32+1/64... |
1/10 | 0.1 or 0.0999... | 0.000110011... | 1/16+1/32+1/256... |
1/11 | 0.090909... | 0.00010111010001011101... | 1/16+1/64+1/128... |
1/12 | 0.08333... | 0.00010101... | 1/16+1/64+1/256... |
1/13 | 0.076923076923... | 0.000100111011000100111011... | 1/16+1/128+1/256... |
1/14 | 0.0714285714285... | 0.0001001001... | 1/16+1/128+1/1024... |
1/15 | 0.0666... | 0.00010001... | 1/16+1/256... |
1/16 | 0.0625 or 0.0624999... | 0.0001 or 0.0000111... | 1/32+1/64+1/128... |
Read more about this topic: Binary Numeral System