Page 252 - ARM 64 Bit Assembly Language
P. 252
Non-integral mathematics 241
the previous example can be expanded as follows:
0
2
1
1 × 2 + 0 × 2 + 1 × 2 + 1 × 2 −1 + 0 × 2 −2 + 1 × 2 −3 + 1 × 2 −4
1 1 1
= 4 + 0 + 1 + + 0 + +
2 8 16
= 5.6875 10
Converting decimal fractions to base sixteen is accomplished in a very similar manner. To
convert 842.234375 10 into base 16, we first convert the integer portion by repeatedly divid-
ing by 16 to yield 34A. We then repeatedly multiply the fractional part, extracting the integer
portion or the result each time as shown in the table below:
Operation Result
Integer Fraction
.234375 × 16 = 3.75 3 .75
.75 × 16 = 12.0 12 .0
In the second line, the integer part is 12, which must be replaced with a hexadecimal digit.
The hexadecimal digit for 12 10 is C, so the fractional part is 3C. Therefore, 842.234375 10 =
34A.3C 16 The result is verified by converting back into base 10 as follows:
2
1
0
3 × 16 + 4 × 16 + 10 × 16 + 3 × 16 −1 + 12 × 16 −2
3 12
= 768 + 64 + 10 + +
16 256
= 842.234375 10
This tabular method works for fractional notation as well as radix-point notation. For exam-
ple, when converting 15 11 to base six, we convert the integer portion by repeatedly dividing
24 10
by six, which results on 23. Then we convert the fractional portion as follows:
Operation Result
Integer Fraction
11 × 6 = 2 3 2 3
24 4 4
3 × 6 = 4 1 4 1
4 2 2
1 × 6 = 3 3 0
2