Hexadecimal is base 16. Much like base 10 uses digits that represent powers of 10 and binary uses digits that represent powers of 2, hexadecimal uses digits that represent powers of 16. Here is how we would interpret \({2047}_{16}\text{:}\)
Using this scheme, \({10}_{16}\) = 1 * 16 + 0 * 1 = \({16}_{10}\text{.}\) Which raises the question “How do we represent ten in hexadecimal?” A 1 in the second column indicates a 16, so we can’t use that - we have to fit all the values up to 15 in the first column. We do so by using the letters A-F to indicate 9-15:
Table4.11.2.Hexadecimal representation of values 10-15
Decimal
Hexadecimal
10
A
11
B
12
C
13
D
14
E
15
F
Thus in the hexadecimal number \({\textrm{1EA}}_{16}\) the E means 14 copies of the second digit (16). The A means 10 copies of the rightmost digit (1):
Subsection4.11.1Hexadecimal Conversion To and From Binary
In hexadecimal, each digit can represent 16 different values: 0-F (0-15). In binary, we can represent the same number of values using 4 bits: 0000-1111 (0-15). What that means, is that each hex digit represents the same information as four binary digits - there is a direct mapping between a hex digit and a four-bit pattern:
Table4.11.4.Hexadecimal - Binary Comparison
Binary
Hexadecimal
Binary
Hexadecimal
0000
0
1000
8
0001
1
1001
9
0010
2
1010
A
0011
3
1011
B
0100
4
1100
C
0101
5
1101
D
0110
6
1110
E
0111
7
1111
F
To convert binary to hex, simply break up the number into groups of 4 digits and convert each group, as in this example (the binary and hexadecimal numerals are both equivalent to decimal 1731).
011011000011
0110
1100
0011
6
C
3
6C3
To convert hex to binary, we can just turn each hex digit into one group of four binary digits, as in this example (the hexadecimal and binary numerals are both equivalent to decimal 161).
A1
A
1
1010
0001
10100001
This video reviews how hexadecimal works and provides a few more examples:
Why would we want another base system? Large binary values are hard for people to read accurately and remember. Try it yourself - quickly try to decide if 0011100101110110 and 0011100101100110 are the same.
Those two binary strings look like this in hex: \({3976}_{16}\) and \({3966}_{16}\text{.}\) In that format, it is a little easier to say the values and to see where the difference is, isn’t it? Because changing switching from binary to hex is so easy, hexadecimal is used to display binary values in a more human-readable form. You will see an example of where this is used in web page design on the next page.
Checkpoint4.11.5.
What decimal value does the hexadecimal number 2A represent?