Introduction to Hexadecimal Numbers
concept
Hexadecimal numbers are a base 16 number system and are incredibly popular these days.
The rules for using hex numbers and converting between them and other systems is very similar to what we've already seen for binary and octal so there won't be much new here.
The only real place you might get tripped up is the introduction of some letters as digits.
Since hexadecimal is a base 16 system we obviously need symbols for handling the digits for "10", "11", "14" etc.
To accomplish this we use the capital letters A-F to represent the digits "10"-"15".
fact
Hexadecimal is a base 16 number system, each digit can have one of 16 values from \(0_{10}\) to \(15_{10}\).
To represent the digits for numbers greater than 9 we use the letters A-F as shown in the table below:
Decimal | Hexadecimal |
---|---|
0 | 0 |
1 | 1 |
2 | 2 |
9 | 9 |
10 | A |
11 | B |
12 | C |
13 | D |
14 | E |
15 | F |
16 | 11 |
17 | 12 |
fact
As a base 16 number system the place values for hexadecimal digits are given by \(16^n\) where \(n\) is the number of digits from the right and starts at 0.
The first 4 place digits are:
Place | 3 | 2 | 1 | 0 |
---|---|---|---|---|
Value | 4096 | 256 | 16 | 1 |
Converting a hex number into decimal follows the exact same process that binary and octal did. Just multiply each digit by its place value and sum.
fact
To convert a hexadecimal number into binary multiply each digit's value by its place value and sum to get the result.
example
Convert \(2A_{16}\) into decimal.
$$2_{16} = 2_{10}$$ And $$A_{16} = 10_{10}$$ So: $$2A_{16} = 2\times 16 + 10\times 1 = 42_{10}$$example
Convert \(C2_{16}\) into decimal.
$$C_{16} = 12_{10}$$ And $$2_{16} = 2_{10}$$ So: $$C2_{16} = 12\times 16 + 2\times 1 = 194_{10}$$ Converting a decimal number into hexadecimal is also the same as converting binary or octal into hexadecimal. We use the SOAR table and the same method but we divide by 16 since we're converting to a base 16 number system.
fact
To convert a decimal number into hexadecimal use a SOAR table.
SOAR stands for:
Step
Operation
Answer
Result
The steps are:
- Divide your decimal number by 16
- Write the integer part of the answer under the "Answer" column
- Write the remaineder part of the answer under the "Remainder" column
- Repeat step 1 with the integer part of your answer until \(A=0\)
- The hexadecimal number is the digits in the "Remainder" column read bottom up
example
Convert \(122_{10}\) to hexadecimal.
We start by drawing up our SOAR table:S | O | A | R |
---|---|---|---|
1 |
S | O | A | R |
---|---|---|---|
1 | \(\frac{122}{16}\) | 7 | A |
S | O | A | R |
---|---|---|---|
1 | \(\frac{122}{16}\) | 7 | A |
2 | \(\frac{7}{16}\) |
S | O | A | R |
---|---|---|---|
1 | \(\frac{122}{16}\) | 7 | A |
2 | \(\frac{7}{16}\) | 0 | 7 |
fact
To convert hexadecimal to binary write each hex digit as a 4-bit binary number.
example
Convert \(28_{16}\) to binary.
$$\begin{align} 2\phantom{00} & \phantom{00}8 \\ 0010\; & \; 1000 \\ \end{align}$$ So we can see that: $$28_{16} = 00101000_2$$example
Convert \(2B6_{16}\) to binary
$$\begin{align} 2 \quad\; B& \quad\;\;\;\; 6 \\ 2 \quad\;\; 1&1\quad\;\; 6 & \\ 0010\; 10&11\; 0110 \\ \end{align}$$ So we can see that: $$2B6_{16} = 001010110110_2$$fact
To convert from binary to hexadecimal group the binary digits in groups of 4 starting from the right and convert each 4-bit binary number into its hexadecimal value.
example
Convert \(110100100_2\) to hexadecimal
We group our number as shown: $$0001\;\;1010\;\;0100$$ Where we've added leading 0s to make up a total of 4 digits for the left-most group. Now we'll convert each of these groups into their decimal value (this step isn't necessary it just makes things a little smoother). $$\begin{align} 0001\;\;10&10\;\;0100 \\ 1\quad\;\;1&0\quad\;\;4 \\ \end{align}$$ And then we convert each of these decimal numbers into their hexadecimal form: $$\begin{align} (0&001\;\;1010\;\;0100)_2 \\ & (1\quad\;\;10\quad\;\;\;4)_{10} \\ & (1\quad\;\;A \quad\;\;\;\;4)_{16} \\ \end{align}$$ $$\text{So:}\quad 110100100_2 = 1A4_{16}$$fact
To convert from hexadecimal to octal or from octal to hexadecimal first convert to binary and then to your desired base.
practice problems