Number systems — binary, hex and two's complement
A fixed MCQ topic every year, and a common short-structured question in Paper II. Every conversion below follows a mechanical method — get the method right once and any number in the question works the same way.
දශමය, ද්විමය සහ hexadecimal අතර පරිවර්තනය කරන ආකාරය මෙතන සරලව පැහැදිලි කර ඇත.
Need logic gates next? Symbols and truth tables, all seven gates.
The four number systems
| System | Base | Digits used | Why it matters |
|---|---|---|---|
| Binary | 2 | 0, 1 | What the computer actually stores and processes. |
| Octal | 8 | 0–7 | Rarely used directly in the A/L syllabus, but a valid base to know. |
| Decimal | 10 | 0–9 | The number system people think in. |
| Hexadecimal | 16 | 0–9, A–F | A compact way to write binary — every hex digit is exactly 4 bits. |
Decimal → binary: divide by 2, read the remainders
Divide by 2 repeatedly until the quotient reaches 0, then read the remainders from the bottom of the list back up to the top.
| Divide | Quotient | Remainder |
|---|---|---|
| 156 ÷ 2 | 78 | 0 |
| 78 ÷ 2 | 39 | 0 |
| 39 ÷ 2 | 19 | 1 |
| 19 ÷ 2 | 9 | 1 |
| 9 ÷ 2 | 4 | 1 |
| 4 ÷ 2 | 2 | 0 |
| 2 ÷ 2 | 1 | 0 |
| 1 ÷ 2 | 0 | 1 |
Reading remainders bottom to top: 10011100. Check it the other way — add up the place values of every 1 bit:
Add only the highlighted place values: 128 + 16 + 8 + 4 = 156
Binary → hexadecimal: group into nibbles of 4
Split the binary number into groups of 4 bits (nibbles) starting from the right, then convert each nibble to its single hex digit.
Read the hex digits left to right: 0x9C
Two's complement: how negative numbers are stored
To store −45 in 8-bit two's complement: write 45 in 8-bit binary, invert every bit, then add 1.
Binary addition, with the carry shown
Add column by column from the right, just like decimal addition — except a bit can only hold 0 or 1, so a carry into the next column happens as soon as the total reaches 2.
Practice questions
Convert 156 (decimal) to binary.
10011100 — divide 156 by 2 repeatedly and read the remainders bottom to top: 156→78 r0, 78→39 r0, 39→19 r1, 19→9 r1, 9→4 r1, 4→2 r0, 2→1 r0, 1→0 r1.
Convert 10011100 (binary) to hexadecimal.
9C — group into 4-bit nibbles from the right: 1001 (=9) and 1100 (=C).
Represent −45 in 8-bit two's complement.
11010011 — write 45 as 00101101, invert every bit to get 11010010, then add 1.
Add the 4-bit binary numbers 1011 and 0110.
10001 (17 in decimal) — the addition carries out of the top bit, so the 4-bit result needs a 5th bit to hold it.
Questions students ask
Why does A/L ICT use hexadecimal at all, if computers only use binary?
Because binary is unreadable at any real length — an 8-bit byte is 8 characters, a 32-bit address is 32. Hexadecimal groups binary into 4-bit nibbles, so the same 8-bit value becomes just 2 hex digits, and converting between them is a mechanical grouping exercise rather than arithmetic.
What is the quickest way to convert decimal to binary?
Divide repeatedly by 2, writing down the remainder each time, until the quotient reaches 0 — then read the remainders from bottom to top. The alternative, subtracting powers of 2 from largest to smallest, works just as well and is often faster to do in your head for exam-sized numbers.
What is two's complement and why is it used?
It's the standard way computers represent negative numbers in binary: invert every bit of the positive value, then add 1. It's used because it lets addition and subtraction use the exact same binary-adder circuit for both positive and negative numbers — no separate "subtract" hardware is needed.
How do I know how many bits a two's complement answer needs?
The question will state it (commonly 8 bits at A/L). Pad the original positive value with leading zeros to that width before you invert — skipping this is the most common mark-losing mistake in two's complement questions.
More free A/L ICT resources
- Free ICT notes & past papers
- Past papers, used the right way
- The full syllabus, unit by unit
- A revision plan, especially for repeats
- Exam command words explained
- 10 worked "distinguish between" answers
- Logic gates, symbols & truth tables
- Where A/L ICT can take you
- Dr. Yasas Sri Wickramasinghe — lecturer profile
Get every conversion drilled until it's automatic
Every subject's Practice section includes number-system conversion questions with instant marking, plus the full data representation unit taught live.
Join a class