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 (base-16, often shortened to "hex") is the third number system you need to know for OCR J277 Section 2.6. Hexadecimal is widely used in computing because it provides a compact, human-readable representation of binary data.
Binary numbers are long and hard for humans to read. Hexadecimal solves this problem:
| Binary (8 bits) | Denary | Hexadecimal |
|---|---|---|
| 11111111 | 255 | FF |
| 10101010 | 170 | AA |
| 00000000 | 0 | 00 |
Hex is shorter and easier to read than binary, while still mapping directly to binary (each hex digit = exactly 4 bits). This is why hex is used for:
| Use | Example |
|---|---|
| Colour codes | #FF5733 (red, green, blue values) |
| MAC addresses | 4A:2B:7C:DE:01:FF |
| Memory addresses | 0x7FFF0000 |
| Error codes | 0x80070005 |
| HTML/CSS colours | color: #00FF00 (green) |
Hex uses 16 digits. Since we only have 10 numeral symbols (0-9), the letters A-F represent values 10-15:
| Hex digit | Denary value | Binary (4 bits) |
|---|---|---|
| 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 |
| A | 10 | 1010 |
| B | 11 | 1011 |
| C | 12 | 1100 |
| D | 13 | 1101 |
| E | 14 | 1110 |
| F | 15 | 1111 |
OCR Exam Tip: You should memorise this table. In the exam, you can quickly write the hex-to-binary lookup in the margin to help with conversions.
flowchart LR
subgraph Byte [8-bit byte split into two nibbles]
N1[Upper nibble - 4 bits] --> H1[Hex digit 1]
N2[Lower nibble - 4 bits] --> H2[Hex digit 2]
end
H1 --> Pair[Hex pair e.g. B7]
H2 --> Pair
Pair --> Use{Used as}
Use --> C1[Colour code #B7...]
Use --> C2[MAC address byte]
Use --> C3[Memory address]
Use --> C4[Error code]
Example: Convert 10110111 to hex
Split: 1011 | 0111
Answer: B7
Example: Convert 11111010 to hex
Split: 1111 | 1010
Answer: FA
Example: Convert 3D to binary
Answer: 00111101
Example: Convert A5 to binary
Answer: 10100101
Multiply each hex digit by its place value (powers of 16):
Example: Convert 2F to denary
| Hex digit | Place value | Calculation |
|---|---|---|
| 2 | 16^1 = 16 | 2 x 16 = 32 |
| F (15) | 16^0 = 1 | 15 x 1 = 15 |
32 + 15 = 47
Example: Convert B4 to denary
176 + 4 = 180
Example: Convert 200 to hex
200 / 16 = 12 remainder 8
Answer: C8
Check: (12 x 16) + 8 = 192 + 8 = 200. Correct!
Alternative method: Convert to binary first, then to hex:
OCR Exam Tip: If you find direct denary-to-hex conversion difficult, convert to binary first, then group into nibbles. This two-step method is perfectly acceptable in the exam.
MAC addresses (media access control addresses) uniquely identify network devices and are written as six pairs of hex digits. Let us decode the first byte of the MAC address 4A:2B:7C:DE:01:FF.
Step 1: Identify the first byte.
The first hex pair is 4A.
Step 2: Convert 4A to binary.
Concatenated: 01001010.
Step 3: Convert 4A to denary.
Step 4: Check via binary-to-denary.
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| 0 | 1 | 0 | 0 | 1 | 0 | 1 | 0 |
64 + 8 + 2 = 74. Agrees with Step 3.
Step 5: Interpret the high-order bits of a MAC address.
Within the first byte, the two lowest bits of the first hex digit carry special meaning for networking. We see 4 = 0100 as the first nibble. Bit 1 (the "locally administered" bit) is 0 and bit 0 (the "multicast" bit) is 0, so this MAC address is a globally unique, unicast address — the standard case for a physical network card.
Step 6: Reconstruct the full binary representation of all six bytes.
| Hex pair | Binary (8 bits) |
|---|---|
| 4A | 01001010 |
| 2B | 00101011 |
| 7C | 01111100 |
| DE | 11011110 |
| 01 | 00000001 |
| FF | 11111111 |
Full 48-bit MAC address: 01001010 00101011 01111100 11011110 00000001 11111111.
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.