| 0.7 |
× 2 = |
1.4 |
1 |
Generate 1 and continue with the rest. |
| 0.4 |
× 2 = |
0.8 |
0 |
Generate 0 and continue. |
| 0.8 |
× 2 = |
1.6 |
1 |
Generate 1 and continue with the rest. |
| 0.6 |
× 2 = |
1.2 |
1 |
Generate 1 and continue with the rest. |
| 0.2 |
× 2 = |
0.4 |
0 |
Generate 0 and continue. |
| 0.4 |
× 2 = |
0.8 |
0 |
Generate 0 and continue. |
| 0.8 |
× 2 = |
1.6 |
1 |
Generate 1 and continue with the rest. |
| 0.6 |
× 2 = |
1.2 |
1 |
Generate 1 and continue with the rest. |
| … |
The reason why the process seems to continue endlessly is that it does.
The number 7/10, which makes a perfectly reasonable decimal fraction, is a
repeating fraction in binary, just as the faction 1/3 is a repeating
fraction in decimal. (It repeats in binary as well.) We cannot represent
this exactly as a floating point number.
The closest we can come in four bits is .1011.
Since we already have a leading 1, the best eight-bit number we
can make is 1.1011.