REVISION GUIDE · IGCSE 0478 AND A LEVEL 9618
Binary, hex and two’s complement cheat sheet
Every number conversion you need for Paper 1, with worked examples: binary, denary, hexadecimal, addition, overflow, shifts, two’s complement and BCD.
Number conversions are some of the most reliable marks in Cambridge Computer Science. Every IGCSE 0478 Paper 1 and every AS Level 9618 Paper 1 includes them, the methods never change, and with a little practice you can get them right every time. This cheat sheet covers everything you need: binary and denary, hexadecimal, binary addition and overflow, logical shifts and two’s complement, plus BCD and binary prefixes for A Level.
1. Binary place values
Binary is base 2. Each column is worth double the column to its right. For an 8-bit number (one byte), learn these place values by heart:
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| 1 | 0 | 1 | 1 | 0 | 1 | 0 | 1 |
To convert binary to denary, add the place values wherever there is a 1. Above: 128 + 32 + 16 + 4 + 1 = 181. The largest 8-bit unsigned value is 11111111 = 255, so 8 bits can store 256 different values (0 to 255).
2. Denary to binary: the subtraction method
Work from the left. If the place value fits into what is left, write 1 and subtract it. If not, write 0.
| Step | Place value | Fits into remainder? | Bit | Remainder |
|---|---|---|---|---|
| 1 | 128 | 181: yes | 1 | 53 |
| 2 | 64 | 53: no | 0 | 53 |
| 3 | 32 | 53: yes | 1 | 21 |
| 4 | 16 | 21: yes | 1 | 5 |
| 5 | 8 | 5: no | 0 | 5 |
| 6 | 4 | 5: yes | 1 | 1 |
| 7 | 2 | 1: no | 0 | 1 |
| 8 | 1 | 1: yes | 1 | 0 |
So 181 = 10110101. Always check your answer by converting it back.
3. Hexadecimal
Hexadecimal (hex) is base 16. It uses the digits 0 to 9 and then the letters A to F for 10 to 15. One hex digit represents exactly four bits (a nibble), which is why programmers use it as a short, readable way to write binary.
| Denary | Binary | Hex | Denary | Binary | Hex |
|---|---|---|---|---|---|
| 0 | 0000 | 0 | 8 | 1000 | 8 |
| 1 | 0001 | 1 | 9 | 1001 | 9 |
| 2 | 0010 | 2 | 10 | 1010 | A |
| 3 | 0011 | 3 | 11 | 1011 | B |
| 4 | 0100 | 4 | 12 | 1100 | C |
| 5 | 0101 | 5 | 13 | 1101 | D |
| 6 | 0110 | 6 | 14 | 1110 | E |
| 7 | 0111 | 7 | 15 | 1111 | F |
Binary to hex: split the binary into groups of four from the right, then convert each group. 1011 0101 → B 5, so 10110101 = B5.
Hex to denary: the left digit is worth 16s and the right digit is worth 1s. B5 = (11 × 16) + 5 = 176 + 5 = 181.
Denary to hex: the easiest route is denary → binary → hex. You can also divide by 16: 181 ÷ 16 = 11 remainder 5, giving B5.
Hex is used for colour codes in HTML (such as #3FD0DB), MAC addresses, IPv6 addresses, memory dumps and error codes. Exam questions often ask why: it is shorter and easier for humans to read and write than binary, with fewer mistakes, and it converts to binary very easily.
4. Binary addition and overflow
There are only four rules: 0 + 0 = 0, 0 + 1 = 1, 1 + 1 = 0 carry 1, and 1 + 1 + 1 = 1 carry 1. Work from right to left and write your carries clearly. Examiners give marks for working.
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | Denary | |
|---|---|---|---|---|---|---|---|---|---|
| 0 | 1 | 1 | 0 | 1 | 1 | 0 | 1 | 109 | |
| + | 0 | 1 | 0 | 1 | 1 | 0 | 1 | 1 | 91 |
| = | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 200 |
Overflow happens when the result is too large to fit in the number of bits available. For example, 11001000 (200) + 01100100 (100) = 300, but the largest 8-bit value is 255. The answer needs a ninth bit, which an 8-bit register cannot store, so only 00101100 (44) is kept and the result is wrong. When asked to explain overflow, say that the result is greater than 255 (for 8 bits), so a carry is produced out of the most significant bit and is lost.
5. Logical binary shifts
A logical shift moves every bit left or right. Bits that fall off the end are lost, and the empty positions are filled with 0s.
- Left shift by 1 multiplies by 2. 00010110 (22) shifted left 2 places = 01011000 (88), which is 22 × 4.
- Right shift by 1 divides by 2 (whole number division). 00010110 (22) shifted right 1 place = 00001011 (11).
- Losing bits makes the result wrong. 00110000 (48) shifted left 3 places = 10000000 (128), not 384, because a 1 was shifted out of the byte.
6. Two’s complement (negative numbers)
In 8-bit two’s complement, the most significant bit has a place value of −128 instead of +128. All the other columns are the same. That gives a range of −128 to +127. If the first bit is 1, the number is negative.
| −128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | Value |
|---|---|---|---|---|---|---|---|---|
| 1 | 0 | 0 | 1 | 1 | 0 | 1 | 0 | −128 + 16 + 8 + 2 = −102 |
Denary to two’s complement, for example −45:
- Write +45 in binary: 00101101
- Invert every bit (flip 0s and 1s): 11010010
- Add 1: 11010011
Check: −128 + 64 + 16 + 2 + 1 = −45. A quick shortcut: copy the bits from the right up to and including the first 1, then flip all the rest.
A Level: subtraction. To work out 57 − 45, add 57 and −45 in two’s complement: 00111001 + 11010011 = 1 00001100. Ignore the carry out of the eighth bit, and the answer is 00001100 = 12.
A Level: one’s complement. In one’s complement you only invert the bits (step 2 above), without adding 1. It has two representations of zero (00000000 and 11111111), which is one reason two’s complement is used instead.
7. BCD and binary prefixes (A Level 9618)
Binary-coded decimal (BCD) stores each denary digit separately in four bits. For example, 59 in BCD is 0101 1001, whereas in pure binary it is 00111011. BCD is used where digits are shown on a display, such as digital clocks and calculators, and in financial systems where exact decimal values matter.
Binary prefixes are powers of 2, while decimal prefixes are powers of 10:
| Binary prefix | Value | Decimal prefix | Value |
|---|---|---|---|
| kibibyte (KiB) | 210 = 1024 bytes | kilobyte (kB) | 103 = 1000 bytes |
| mebibyte (MiB) | 220 bytes | megabyte (MB) | 106 bytes |
| gibibyte (GiB) | 230 bytes | gigabyte (GB) | 109 bytes |
| tebibyte (TiB) | 240 bytes | terabyte (TB) | 1012 bytes |
Mistakes that cost marks
- Giving fewer than 8 bits when the question asks for an 8-bit answer. Always pad with leading 0s, for example 00001011, not 1011.
- Grouping binary into fours from the left instead of the right when converting to hex.
- Writing 10 to 15 as two digits in hex instead of A to F.
- Not showing carries in binary addition, so no method marks can be given.
- Saying overflow is when the answer is negative. It is when the result is too large for the number of bits.
- Forgetting to add 1 after inverting the bits in two’s complement.
- Treating the first bit of a two’s complement number as +128 instead of −128.
- Confusing kilobyte (1000 bytes) with kibibyte (1024 bytes) in A Level questions.
Read the question carefully too. A question that says “show your working” has method marks attached, so set out each step clearly. Our command words guide explains what each instruction word expects.
Practise next
- IGCSE: Data representation (0478 unit 1), with an interactive binary converter and self-marking practice.
- AS Level: Information representation (9618), covering BCD, two’s complement and binary prefixes.
- A2 Level: Data representation (A Level), which builds on this with floating-point numbers.
Frequently asked questions
Do I need two’s complement for IGCSE Computer Science 0478?
Yes. IGCSE students need to convert positive and negative denary numbers to and from 8-bit two’s complement. Binary subtraction and one’s complement are only needed at A Level.
What is the range of an 8-bit two’s complement number?
From −128 (10000000) to +127 (01111111). An unsigned 8-bit number has a range of 0 to 255.
Why do computer scientists use hexadecimal?
Hex is shorter and easier for people to read, write and remember than long binary numbers, so there are fewer mistakes. Each hex digit maps exactly to four bits, so it converts to and from binary very easily.
Want to make conversions automatic?
Book a free 30-minute online lesson and we will work through exam-style number questions together. Book a free demo →