Hexadecimal Numbers
Review
Memory contains:
f800: 40
f801: 97
f802: 12
f803: 0d
PC contains f801, A contains 24. What happens?
What is 43 in binary? 101011
Hexadecimal numbers
Problem with binary: writing all those 1's and 0's gets tedious.
But notice that four bits is capable of representing a number from 0 to
15. This means that we can ``scoop up'' groups of 4 bits and treat
them as numbers in base 16 (hexadecimal, or hex). Does it work?
Let's convert 43 to hex. We get 2,11. Another problem! We don't have
enough digits. So, we use a=10, b=11, and so forth to f=15 when we're
working in hex. Now, we can go back and look at those screwy numbers
we've been using -- what's f800 in binary? How about decimal?
As you might expect, we can indeed do addition in hexadecimal. So,
what would
3592
+4f9a
be?
Radix conversions: decimal, hex, binary
Here's a table, showing the translations between the common number
bases for the first sixteen numbers.
Decimal |
Hexadecimal |
Octal |
Binary |
0 | 0 | 0 | 0000 |
1 | 1 | 1 | 0001 |
2 | 2 | 2 | 0010 |
3 | 3 | 3 | 0011 |
4 | 4 | 4 | 0100 |
5 | 5 | 5 | 0101 |
6 | 6 | 6 | 0110 |
7 | 7 | 7 | 0111 |
8 | 8 | 10 | 1000 |
9 | 9 | 11 | 1001 |
10 | a | 12 | 1010 |
11 | b | 13 | 1011 |
12 | c | 14 | 1100 |
13 | d | 15 | 1101 |
14 | e | 16 | 1110 |
15 | f | 17 | 1111 |