Converting decimal (denary) into hexadecimal is very simple. All we need is to remember that hexadecimal is a base 16 number. This means that each number column can contain 16 characters. Hexadecimal goes from 0 to F:
Decimal Number | Hexadecimal Number |
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 |
EG
Using the table – 7 in decimal is 7 in hexadecimal.
Using the table – 10 in decimal is A in hexadecimal.
Denary to Hexadecimal Conversion to 2 figures
In GCSE computer science you will be expected to convert denary into 2 figure hexadecimal. Again we need to remember that hexadecimal is a base 16 number and each number column can go from 0-9 and A-F.
Example 1
Convert decimal number 162 into hexadecimal
Draw out a 2 column table with 16 on the left and 1 on the right. We now take our original number and divide it by 16
16 | 1 |
162 / 16 = 10 remainder 2 |
The answer is 10 (16 x 10 = 160) and gives us a remainder of 2. The remainder of 2 is then carried across to the 1 column. The remainder is then divided by 1.
16 | 1 |
162 / 16 = 10 | 2 / 1 = 2 |
We now need to check our columns to see if any number needs converting to a hexadecimal character. In the 16 column we have a 10. A 10 in hexadecimal is the letter A so we substitute the 10 for an A.
16 | 1 |
162 / 16 = 10 | 2 / 1 = 2 |
10 = A | 2 = 2 |
= A | = 2 |
The final step is to put the 2 columns together
162 in denary = A2 in hexadecimal
Example 2
Convert decimal number 40 into hexadecimal
16 | 1 |
40 / 16 = 2 remainder 8 | 8 / 1 = 8 |
2 = 2 | 8 = 8 |
= 2 | = 8 |
40 in decimal = 28 in hexadecimal