|
|
|
|
|
|
|
|
|
|
|
|
Converting number bases:
fractions |
|
|
|
Given: decimal fraction
representation |
|
|
Find: binary
representation |
|
|
|
|
value: |
0.375ten |
|
|
b-1 |
b-2 |
b-3 |
b-4 |
b-5 |
|
|
weight |
|
2-1 |
2-2 |
2-3 |
2-4 |
2-5 |
|
|
|
|
0.5 |
0.25 |
0.125 |
0.0625 |
0.03125 |
|
|
digit |
0. |
0 |
1 |
1 |
0 |
0 |
|
|
|
|
|
To convert a
whole number, we successively divided by 2 |
|
|
What should we do with a
fraction? |
|
|
0.375ten |
= b-1 * 2-1 + b-2 * 2-2 + b-3 * 2-3 + b-4 * 2-4 + etc. |
|
|
If we multiply by 2, |
|
|
|
|
|
|
0.750 |
= b-1* 20 + b-2 * 2-1 + b-3 * 2-2 + b-4 * 2-3 + etc. |
|
|
Result is still less than
1, so b-1 must be 0,
since we assume all digits are positive |
|
|
Multiply by 2 again, |
|
|
|
|
|
1.50 |
= b-2 * 20 + b-3 * 2-1 + b-4 * 2-2 + etc. |
|
|
Now we know that b-2 must be 1, since the rest
of the expression is a fraction: |
|
|
|
0.50 |
= b-3 * 2-1 + b-4 * 2-2 + etc. |
|
|
Repeat the process: |
|
|
|
|
|
1.00 |
= b-3 * 20 + b-4 * 2-1 + etc. |
|
|
|
0.00 |
= b-4 * 2-1 + b-5 * 2-2 |
|
|
What are all the bits to
the right? |
|
|
|
0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|