ICTCampus

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

SystemBaseDigits usedWhy it matters
Binary20, 1What the computer actually stores and processes.
Octal80–7Rarely used directly in the A/L syllabus, but a valid base to know.
Decimal100–9The number system people think in.
Hexadecimal160–9, A–FA 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.

DivideQuotientRemainder
156 ÷ 2780
78 ÷ 2390
39 ÷ 2191
19 ÷ 291
9 ÷ 241
4 ÷ 220
2 ÷ 210
1 ÷ 201

Reading remainders bottom to top: 10011100. Check it the other way — add up the place values of every 1 bit:

128
1
64
0
32
0
16
1
8
1
4
1
2
0
1
0

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.

1
0
0
1
9
1
1
0
0
C

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.

Original
0
0
1
0
1
1
0
1
Invert every bit
1
1
0
1
0
0
1
0
Add 1
1
1
0
1
0
0
1
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.

carry
1
1
0
0
1
0
1
1
+
0
1
1
0
=
1
0
0
0
1

Practice questions

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

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