Page 30 - ARM 64 Bit Assembly Language
P. 30
Introduction 13
bits results in 0001|0011|0001|0011 2 . Looking up the four groups in the table reveals that
0001|0011|0001|0011 2 = 1313 16 .
1.3.2.4 Conversion between arbitrary bases
It is possible to perform the division and multiplication steps in any base and directly convert
from any base to any other base. However, most people are much better at working in base
ten. For that reason, the easiest and least error-prone way to convert from any base a to any
other base b is to use a two step process. The first step is to convert from base a to base ten.
The second step is to convert from base ten to base b.
Example 3. Converting 42301 5 to base 11 is accomplished with two steps.
The number is first converted to base ten as follows:
4
3
1
2
42301 5 = 4 × 5 + 2 × 5 + 3 × 5 + 0 × 5 + 1 × 5 0
= 4 × 625 + 2 × 125 + 3 × 25 + 0 × 5 + 1 × 1
= 2500 + 250 + 75 + 0 + 1
= 2826 10
Then the result is converted to base 11:
0
256 → 23 → 2 →
11 2826 11 256 11 23 11 2
2200 220 22
626 36 1
550 33
76 3
66
10
42301 5 = 2826 10 = 213A 11
1.3.3 Representing integers
The computer stores groups of bits, but the bits by themselves have no meaning. The pro-
grammer gives them meaning by deciding what the bits represent, and how they are inter-
preted. Interpreting a group of bits as unsigned integer data is relatively simple. Each bit is
weighted by a power-of-two, and the value of the group of bits is the sum of the non-zero
bits multiplied by their respective weights. However, programmers often need to represent
negative as well as non-negative numbers, and there are many possibilities for storing and