You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Hexadecimal (often shortened to hex) is a base-16 number system. It is widely used in computing as a more human-friendly way of representing binary data. This lesson explains how hexadecimal works and why it is useful.
Hexadecimal uses 16 symbols to represent values:
| Denary | Hex | Binary (4-bit) |
|---|---|---|
| 0 | 0 | 0000 |
| 1 | 1 | 0001 |
| 2 | 2 | 0010 |
| 3 | 3 | 0011 |
| 4 | 4 | 0100 |
| 5 | 5 | 0101 |
| 6 | 6 | 0110 |
| 7 | 7 | 0111 |
| 8 | 8 | 1000 |
| 9 | 9 | 1001 |
| 10 | A | 1010 |
| 11 | B | 1011 |
| 12 | C | 1100 |
| 13 | D | 1101 |
| 14 | E | 1110 |
| 15 | F | 1111 |
Because hex needs 16 symbols but we only have 10 numerical digits (0–9), the letters A to F are used to represent the values 10 to 15.
Hexadecimal is used because:
It is a shorthand for binary. Each hex digit maps exactly to 4 binary bits (a nibble). This makes conversion between hex and binary very quick and straightforward.
It is more compact. An 8-bit binary number like 11111111 can be written as just FF in hex. This reduces the chance of making errors when reading or writing long binary strings.
It is easier for humans to read and remember. Hex values are much shorter than their binary equivalents, making them more practical for programmers and engineers.
flowchart TD
A[Hex digit] --> B[Lookup 4-bit nibble]
B --> C[Concatenate nibbles]
C --> D[8-bit binary number]
A --> E[digit x 16 + next digit]
E --> F[Denary value]
D --> F
Each hex digit converts directly to a 4-bit binary nibble. Simply replace each hex digit with its 4-bit binary equivalent.
Worked Example: Convert 3F to binary.
3F in hex = 00111111 in binary
Worked Example: Convert A7 to binary.
A7 in hex = 10100111 in binary
Split the binary number into groups of 4 bits from the right, then convert each group to its hex equivalent.
Worked Example: Convert 11010110 to hex.
11010110 in binary = D6 in hex
Worked Example: Convert 101111001 to hex (9 bits).
101111001 in binary = 179 in hex
Each hex digit has a place value based on powers of 16:
| 16¹ (16s) | 16⁰ (1s) |
|---|---|
| First digit | Second digit |
Multiply each hex digit by its place value and add the results.
Worked Example: Convert 2E to denary.
Worked Example: Convert B4 to denary.
Divide the denary number by 16. The quotient is the first hex digit; the remainder is the second hex digit.
Worked Example: Convert 200 to hex.
200 in denary = C8 in hex
Worked Example: Convert 255 to hex.
255 in denary = FF in hex
Hex to Binary
So 4D in hex = 01001101 in binary.
Binary to Denary
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| 0 | 1 | 0 | 0 | 1 | 1 | 0 | 1 |
64 + 8 + 4 + 1 = 77.
Cross-check via direct hex-to-denary: 4 × 16 + 13 × 1 = 64 + 13 = 77. The two routes agree.
220 ÷ 16 = 13 remainder 12.
So 220 in denary = DC in hex.
Verification via binary: 220 = 128 + 64 + 16 + 8 + 4 = 11011100. Splitting into nibbles gives 1101 | 1100 = D | C = DC. The two methods agree.
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.