LESSON NOTE
|
Decimal |
Hex |
0 |
0 |
1 |
1 |
2 |
2 |
3 |
3 |
4 |
4 |
5 |
5 |
6 |
6 |
7 |
7 |
8 |
8 |
9 |
9 |
10 |
A |
11 |
B |
12 |
C |
13 |
D |
14 |
E |
15 |
F |
WHY IS HEX POPULAR?
Hex is popular because it can be used as
a convenient representation of binary.
It turns out that four digits in binary can be replaced by 1 digit in
hex. This makes converting between
binary and hex extremely easy.
Look at the table below. Notice that at the end of the table, both
hex and binary would have to add a new digit.
Because of this, we can always swap four binary digits for one hex
digit.
Hex |
Binary |
0 |
0000 |
1 |
0001 |
2 |
0010 |
3 |
0011 |
4 |
0100 |
5 |
0101 |
6 |
0110 |
7 |
0111 |
8 |
1000 |
9 |
1001 |
A |
1010 |
B |
1011 |
C |
1100 |
D |
1101 |
E |
1110 |
F |
1111 |
To
convert, we simply replace each hex digit with the four corresponding binary
digits. The table above is a helpful guide.
2A
= 0010 1010
AB11
= 1010 1011 0001 0001
32C
= 0011 0010 1100
110
= 0001 0001 0000
To
convert, we simply replace each sequence of four binary digits by the
corresponding hex digit. It may be necessary to add zeros at the
beginning of the number to make sure that the number has a proper number of
bits.
0011
= 3
1111
0010 = F2
1001
1100 = 9C
111
= 0111 (after adding leading zero) = 7
11 0010 = 0011 0010 (after adding
two leading zeros) = 32
The
location where decimal needs a new digit does not match up with the location
where binary needs a new digit. Therefore, each decimal digit
cannot be associated to specific number of bits.
Decimal |
Binary |
0 |
0000 |
1 |
0001 |
2 |
0010 |
3 |
0011 |
4 |
0100 |
5 |
0101 |
6 |
0110 |
7 |
0111 |
8 |
1000 |
9 |
1001 |
? |
1010 |
? |
1011 |
? |
1100 |
? |
1101 |
? |
1110 |
? |
1111 |