Binary, denary and hexadecimal conversion
▶ Watch the video lessonShort, exam-focused explanation of this topic on the CS with Aamir YouTube channel.Computers store all data as binary – patterns of 1s and 0s – because their circuits are built from switches that are either on or off. People find long binary numbers hard to read, so we also use denary (base 10) and hexadecimal (base 16). In the exam you must be able to convert between all three.
Binary place values
Each binary digit (bit) has a place value that doubles from right to left. For an 8-bit binary number (one byte) the place values are:
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|
Binary to denary
Write the binary number under the place values and add up every place value that has a 1 under it.
Denary to binary
Start at the largest place value (128). If it fits into the number, write 1 and subtract it; if not, write 0. Move to the next place value and repeat until you reach 1.
Hexadecimal digits
Hexadecimal uses 16 digits: 0–9, then A = 10, B = 11, C = 12, D = 13, E = 14 and F = 15. One hex digit represents exactly 4 bits (a nibble), which is why conversion between binary and hex is so quick.
Binary to hexadecimal
Split the binary number into groups of 4 bits starting from the right, then convert each group to one hex digit.
Hexadecimal to binary
Convert each hex digit into its 4-bit binary pattern and join them together.
Hexadecimal to denary
The place values in hexadecimal are 256, 16 and 1. Multiply each digit by its place value and add.
To go from denary to hex, you can convert the number to binary first and then group into nibbles, or divide by 16: 200 ÷ 16 = 12 remainder 8 → C8.
Why do we use hexadecimal?
- It is much shorter than binary, so it is easier for people to read, write and remember.
- There is less chance of making a mistake when copying it.
- It converts easily to and from binary.
Common uses you should be able to name include HTML colour codes (e.g. #FF0000 for red), MAC addresses, IPv6 addresses and error codes.
Exam tips
- Always show your working – method marks are available.
- Check your answer by converting it back the other way.
- When asked for an 8-bit answer, add leading zeros (75 is 01001011, not 1001011).
- Remember: hexadecimal is only a way for people to read binary – the computer still stores it as binary.