Hardware Reference
In-Depth Information
If a decimal number has a fractional part, then it needs to be converted using a different
method. The fractional part can be converted to a decimal by performing the repeated-multi-
plication-by-2 operation to the fraction until either the fraction part becomes 0 or the required
accuracy is achieved. The resulting integer binary digit of the first multiplication is the most
significant binary digit of the fractional part whereas the resulting integer binary digit of the
last multiplication is the least significant binary digit of the fractional part.
Let m and k be the number of digits of the decimal fraction and the binary fraction, respec-
tively; then the desired accuracy has been achieved if and only if the following expression is
true:
2 2 k , 10 2 m
A few pairs of k and m values that satisfy the previous relationship are shown in Table B.1.
To be more accurate, if the resultant fractional part of the last multiplication is 5 or larger, then
we should round it up by adding 1 to the least significant binary digit.
k
m
.5 4
1
.5 7
2
.5 10
3
.5 14
4
Table B.1 k and m that
satisfies 2 2 k , 10 2 m
Example B.3
Convert the decimal fraction 0.6 to binary.
Solution: According to Table B.1, we need to perform four repeated-multiplication-by-2 opera-
tions as shown in Figure B.3.
0
×
.6
2
The most significant digit
1. 2
2
×
0. 4
×
2
0. 8
×
2
Round up because
6 ≥ 5
The least significant digit
1. 6
Figure B.3 Convert a decimal fraction to a binary fraction
0.6 10 5 0.1001 2 1 0.0001 2 5 0.1010 2
Search WWH ::




Custom Search