Page 324 - Embedded Microprocessor Systems Real World Design
P. 324
0100 = 4 = (0 x 1) + (0 x 2) + (1 x 4) + (0 x 8)
1101=13=(1~1)+(0~2)+(1~4)+(1~8)
0010 = 2 =(O xl) +(1 x2) +(O x 4) +(O x 8)
Just to clarlfy what we are doing, we will rewrite the original grouped binary number with
the corresponding values:
Binary: 0100 1101 0010
Decimal: 4 13 2
Notice that these are the same values we multiplied by the powers of 16 when we first broke
the number into 4bit groups:
Binary: 0100 1101 0010
Decimal: 4x256 13x16 2x1
So our original binary number can be written as a Wigit, base-16 number (4, 13, 2).
The only problem with this is how to write the numbers. We need a single character to
represent each digit, even those greater than 9. Otherwise we can't tell the difference
between the digit value 13 and the two digits 1 and 3. Since the decimal system cannot
represent digits greater than 9, the alphabet characters A-F are used for the extended digits,
like this:
Decimal Binary Hex
0 0000 0
1 0001 1
2 001 0 2
3 001 1 3
4 01 00 4
5 01 01 5
6 0110 6
7 0111 7
8 1000 8
9 1001 9
10 1010 A
11 1011 B
12 1100 C
13 1101 D
14 1110 E
15 1111 F
We can now write our number in three different bases:
12341" = 10011010010~ = 4D216
Because many text editors (especially those from the early days of computers) can't handle
subscripts, the numbers are often written without subscripts. Instead, a b suffix is used for
binary, and h for hex, as follows:
Appendix B 305