You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
This lesson covers the three number systems you need for OCR A-Level Computer Science (H446): binary (base 2), denary (base 10), and hexadecimal (base 16). You must be confident converting between all three and understanding where each is used in computing.
Computers operate using electrical signals that are either on (1) or off (0). This makes binary the natural language of hardware. However, binary numbers quickly become very long and hard to read, so hexadecimal provides a compact shorthand. Denary is the number system humans use every day.
| System | Base | Digits Used | Example |
|---|---|---|---|
| Binary | 2 | 0, 1 | 11010110 |
| Denary | 10 | 0-9 | 214 |
| Hexadecimal | 16 | 0-9, A-F | D6 |
Each digit in a binary number is called a bit (binary digit). Each position represents a power of 2, starting from the right at 2^0.
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| 2^7 | 2^6 | 2^5 | 2^4 | 2^3 | 2^2 | 2^1 | 2^0 |
| Term | Definition |
|---|---|
| Bit | A single binary digit (0 or 1) |
| Nibble | 4 bits |
| Byte | 8 bits |
| Word | The number of bits a processor can handle in one operation (commonly 32 or 64 bits) |
Use the subtraction method: write out powers of 2 from the largest that fits, subtract from the denary number, place a 1 in that column, and repeat.
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| 1 | 0 | 1 | 0 | 1 | 1 | 0 | 1 |
173 in denary = 10101101 in binary
Add up the place values where there is a 1.
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| 1 | 1 | 0 | 0 | 1 | 0 | 1 | 0 |
128 + 64 + 8 + 2 = 202
Hexadecimal uses 16 digits. Since we only have 10 numerical digits (0-9), the letters A-F represent values 10-15.
| Hex | Denary | Binary (nibble) |
|---|---|---|
| 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 |
Split the binary number into nibbles (groups of 4 bits) starting from the right, then convert each nibble to its hex digit.
11010110 in binary = D6 in hexadecimal
Convert each hex digit to its 4-bit binary equivalent.
3F in hexadecimal = 00111111 in binary
Multiply each hex digit by its place value (powers of 16) and add.
Divide by 16 repeatedly, noting remainders.
254 in denary = FE in hexadecimal
| Use Case | Example | Why Hex? |
|---|---|---|
| Colour codes | #FF5733 (RGB) | Two hex digits per colour channel (red, green, blue), representing 0-255 |
| MAC addresses | 00:1A:2B:3C:4D:5E | Six pairs of hex digits identify network hardware |
| Memory addresses | 0x7FFF0000 | Compact representation of large binary addresses |
| Error codes | 0x80070005 | Easier to read and remember than binary |
| Assembly/machine code | MOV AX, 0xFF | Compact representation of binary instructions |
| IPv6 addresses | 2001:0db8:85a3::8a2e | Hexadecimal groups separated by colons |
Exam Tip: When asked why hexadecimal is used instead of binary, always state that hex is a more compact and human-readable representation of binary data. Each hex digit represents exactly 4 bits (one nibble), making conversion between the two trivial.
| Mistake | How to Avoid |
|---|---|
| Forgetting to pad nibbles with leading zeros | Always write 4 bits per nibble (e.g., 3 = 0011, not 11) |
| Mixing up hex digits A-F with denary | Remember A=10, B=11, C=12, D=13, E=14, F=15 |
| Reading binary place values left to right as 1, 2, 4... | Place values go right to left: 1, 2, 4, 8, 16, 32, 64, 128 |
| Forgetting that hex is base 16, not base 8 | The place values are 16^0=1, 16^1=16, 16^2=256, etc. |
Exam Tip: Practise conversions until they are second nature. In the exam, show your working clearly — you can earn method marks even if the final answer is wrong. Always double-check by converting your answer back to the original base.