Hexadecimal to Denary Conversion
You can turn a two-digit hexadecimal number into denary by going through binary. Split the hexadecimal number into its two digits, change each digit into a 4-bit nibble, join the nibbles into 8 bits, then add up the column headings wherever a 1 appears.
Each hexadecimal digit stands for one nibble, so it has a fixed 4-bit pattern built from the nibble column headings 8, 4, 2 and 1. Digits 0 to 9 use their usual value; letters A to F mean 10 to 15. For example, 2 is 0010, while A means 10, which is 8 + 2, giving 1010.
The nibbles are placed side by side in the order they appear. The left digit supplies the left four bits and the right digit supplies the right four bits, so the nibbles are not added together. Take 2A: 2 is 0010 and A (10, which is 8 + 2) is 1010, so together they make 00101010.
Now read the 8 bits against the column headings 128, 64, 32, 16, 8, 4, 2 and 1, and add only the columns holding a 1. For 00101010 the 1s sit in the 32, 8 and 2 columns, so the denary value is 32 + 8 + 2 = 42.
The point of the route through binary is that it shows how the hexadecimal digits build up one byte: each nibble is a small binary number, and joining them lines up all eight columns.
| Hexadecimal digit | Denary value | 4-bit nibble |
|---|---|---|
| 4 | 4 | 0100 |
| 9 | 9 | 1001 |
| A | 10 | 1010 |
| D | 13 | 1101 |
| F | 15 | 1111 |
The place-value method on the same number gives 42 too, so the two routes agree.
OCR GCSE Computer Science · Hexadecimal to Denary Conversion