Sample notes 4 min read By Samuel

Number Systems & Binary Arithmetic — Free HKDSE ICT Study Notes

Number systems and binary operations appear in every HKDSE ICT paper — sometimes subtly (parity-bit error detection in MCQs), sometimes explicitly (binary arithmetic in structured questions). This cheatsheet covers what you must know: conversions, two’s complement, arithmetic operations, BCD, Gray code, and storage-size calculations.

If you can do every worked example below without checking, you’re exam-ready for this topic.

Binary ↔ Decimal ↔ Hexadecimal Conversions

The basics

BaseNameDigits
2Binary0, 1
10Decimal0–9
16Hexadecimal0–9, A–F

Hexadecimal digits A–F: A=10, B=11, C=12, D=13, E=14, F=15

Binary ↔ Decimal

Binary to decimal — multiply each bit by its position value (powers of 2, right to left).

Example: Convert 1101₂ to decimal

1 × 2³ = 8
1 × 2² = 4
0 × 2¹ = 0
1 × 2⁰ = 1
Sum = 8 + 4 + 0 + 1 = 13

Decimal to binary — repeatedly divide by 2, collect remainders bottom to top.

Example: Convert 25 to binary

25 ÷ 2 = 12 remainder 1
12 ÷ 2 = 6  remainder 0
6 ÷  2 = 3  remainder 0
3 ÷  2 = 1  remainder 1
1 ÷  2 = 0  remainder 1

Read bottom to top: 11001₂

Verify: 16 + 8 + 0 + 0 + 1 = 25 ✓

Binary ↔ Hexadecimal

Group binary into 4-bit chunks (pad with leading zeros if needed). Map each chunk to a hex digit.

HexBinaryHexBinary
0000081000
1000191001
20010A1010
30011B1011
40100C1100
50101D1101
60110E1110
70111F1111

Example: Convert 11010110₂ to hexadecimal

1101 0110
↓    ↓
 D    6

Result: D6₁₆

Example: Convert 3F₁₆ to binary

3 → 0011
F → 1111

Result: 0011 1111₂

Two’s Complement Signed Integers

Two’s complement is how computers represent negative numbers. The most significant bit (MSB) is the sign bit: 0 = positive, 1 = negative.

4-bit two’s complement range

A 4-bit two’s complement number can represent −8 to +7:

BinaryDecimalBinaryDecimal
1000−800000
1001−700011
1010−600102
1011−500113
1100−401004
1101−301015
1110−201106
1111−101117

Finding the two’s complement

To negate a number: invert all bits, then add 1.

Example: Find −5 in 8-bit two’s complement

Step 1: Write +5 in binary: 0000 0101
Step 2: Invert bits:         1111 1010
Step 3: Add 1:               1111 1011

Result: −5 = 1111 1011₂

Ascending-order trap: In two’s complement, the binary order does not match magnitude order. For 4-bit, 1000₂ (−8) is less than 1111₂ (−1), but 1000₂ > 1111₂ numerically. Don’t sort signed binary numbers as if they were unsigned.

Binary Arithmetic

Addition

Same rules as decimal, base 2. Carry occurs when 1 + 1 = 10₂.

ABSumCarry
0000
0110
1010
1101

Example: Add 1101₂ (13) and 1011₂ (11)

   1101
 + 1011
 ------
  11000₂

Verify: 13 + 11 = 24 ✓

Subtraction via two’s complement

Computers subtract by adding the negative. A − B = A + (−B) where (−B) is B’s two’s complement.

Example: Subtract 0101₂ (5) from 1010₂ (10)

A = 1010₂ (10)
B = 0101₂ (5)

Step 1: Two's complement of B
  0101 → invert → 1010
  1010 + 1 = 1011₂ (this is −5)

Step 2: Add A + (−B)
  1010 + 1011 = 10101₂

Step 3: Discard overflow carry (leftmost bit)
  101₂ = 5

Verify: 10 − 5 = 5 ✓

Overflow detection

In fixed-width arithmetic (e.g., 8-bit), the result might not fit. Overflow occurs when:

  • Adding two positive numbers gives a negative result
  • Adding two negative numbers gives a positive result
  • Adding positive + negative never overflows

Example (4-bit): 0100₂ (+4) + 0101₂ (+5) = 1001₂ (−7 in two’s complement)

Result is negative, but both inputs were positive → overflow. The correct answer (+9) doesn’t fit in 4-bit two’s complement (range −8 to +7).

BCD and Gray Code

These are alternate binary representations, each with specific purposes.

BCD (Binary Coded Decimal)

BCD encodes each decimal digit separately using 4 bits.

DecimalBCDDecimalBCD
0000050101
1000160110
2001070111
3001181000
4010091001

Example: Convert 259 to BCD

2 → 0010
5 → 0101
9 → 1001

Result: 0010 0101 1001 (BCD)

BCD is NOT the same as pure binary: 259₁₀ = 100000011₂ in pure binary, but 0010 0101 1001 in BCD.

When examined: BCD appears in questions about financial systems or displays where exact decimal representation matters (avoids floating-point rounding errors).

Gray Code

Gray code ensures only one bit changes between consecutive values. This prevents brief invalid states in hardware (encoders, sensors).

Binary → Gray: MSB stays same; each subsequent bit = XOR of current binary bit and previous binary bit.

Example: Convert 1011₂ to Gray code

Binary:     1 0 1 1
Gray MSB:   1 (same)
Bit 2: 1⊕0 = 1
Bit 3: 0⊕1 = 1
Bit 4: 1⊕1 = 0

Result: 1110 (Gray)

When examined: Gray code appears in questions about rotary encoders, Karnaugh maps, or error-resistant signal transmission.

Storage-Size Questions

These questions ask: What’s the minimum storage needed for N distinct values?

Formula

For N distinct values, minimum bits n where 2ⁿ ≥ N.

Then round UP to whole bytes (1 byte = 8 bits).

Worked example: RFID tag

Question: An RFID system needs to uniquely identify 500 items. What’s the minimum storage required?

Step 1: Find minimum bits

2⁸ = 256 (not enough)
2⁹ = 512 (enough)

Minimum bits = 9

Step 2: Round up to bytes

9 bits ÷ 8 = 1.125 bytes
Round UP = 2 bytes

Answer: Minimum 2 bytes (16 bits). This can represent 65,536 unique IDs — far more than the 500 required, but storage comes in byte-sized chunks.

Common pattern in past papers

Questions like DSE 2015 Paper 1 Q5 (RFID tag storage) test this exact formula: find 2ⁿ ≥ N, then round up to bytes.

Self-Check Questions

Test yourself. Answers are in the collapsible below.

  1. Convert 10110011₂ to decimal and hexadecimal.
  2. Find the 8-bit two’s complement representation of −42.
  3. Add 0110₂ and 0101₂ in binary. Does overflow occur in a 4-bit system?
  4. Convert 38₁₀ to BCD.
  5. How many bytes are needed to store 2000 unique values?
Click for answers
  1. Decimal: 128 + 32 + 16 + 2 + 1 = 179 | Hex: Group as 1011 0011 → B3₁₆
  2. −42 in 8-bit two’s complement: +42 = 0010 1010 → invert → 1101 0101 → add 1 → 1101 0110₂
  3. Sum: 0110 + 0101 = 1011₂ (decimal 11). No overflow — both inputs positive, result positive.
  4. BCD: 3 → 0011, 8 → 1000 → 0011 1000 (BCD)
  5. Bytes needed: 2¹⁰ = 1024 (not enough), 2¹¹ = 2048 (enough) → 11 bits → round to 2 bytes

Want full notes and more practice?

This is a sample of our HKDSE ICT notes. The full set covers every syllabus topic with worked examples, past-paper patterns, and exam technique.

Explore our complete HKDSE ICT notes — structured for revision, optimized for exam day.

Need personal feedback? Book a trial lesson — we’ll review your answers, fix your misconceptions, and build your targeted study plan.

Keep going

Number systems sit inside the HKDSE ICT complete guide’s study plan. For the databases elective, see the SQL survival guide and ER & normalisation notes.

← All articles

Get the full set with our classes

💬 Chat