IGCSE Computer Science (0478) – Data Representation
1. Number Systems
1.1 Why computers use binary
- Electronic circuits have two stable states: off (low voltage) and on (high voltage).
- Representing data with 0 (off) and 1 (on) is reliable, cheap and fast – this is the basis of the binary system.
- All other number systems (decimal, hexadecimal, octal) are simply convenient ways for humans to read and write the binary data.
1.2 Overview of the three bases used in the syllabus
- Denary (Decimal) – base 10, digits 0‑9.
- Binary – base 2, digits 0 and 1. Each position represents a power of 2.
- Hexadecimal – base 16, digits 0‑9 and A‑F. Each position represents a power of 16 (or exactly four binary bits).
1.3 Quick conversion check – Hex ↔ Binary
Because one hex digit = four binary bits, conversion is immediate:
| Hex digit | Binary (4‑bit) |
| 0 | 0000 |
| 1 | 0001 |
| 2 | 0010 |
| 3 | 0011 |
| 4 | 0100 |
| 5 | 0101 |
| 6 | 0110 |
| 7 | 0111 |
| 8 | 1000 |
| 9 | 1001 |
| A | 1010 |
| B | 1011 |
| C | 1100 |
| D | 1101 |
| E | 1110 |
| F | 1111 |
Example: 3F₁₆ → 0011 1111₂
2. Converting Positive Numbers (Denary ↔ Binary)
2.1 Binary → Decimal (positive)
- Write the binary number and label each bit with its power of 2, starting with
2⁰ on the far right.
- Multiply each bit by its corresponding power of 2.
- Sum all the products – the total is the decimal value.
Example: Convert 101101₂ to decimal.
| Bit (bi) | Power of 2 (2i) | Product |
| 1 (MSB) | 2⁵ = 32 | 32 |
| 0 | 2⁴ = 16 | 0 |
| 1 | 2³ = 8 | 8 |
| 1 | 2² = 4 | 4 |
| 0 | 2¹ = 2 | 0 |
| 1 (LSB) | 2⁰ = 1 | 1 |
Sum = 32 + 0 + 8 + 4 + 0 + 1 = 45. Hence 101101₂ = 45₁₀.
2.2 Decimal → Binary (positive)
Both methods are accepted in the exam. Choose the one you find quickest.
2.2.1 Repeated Division by 2
- Divide the decimal number by 2.
- Write down the remainder (0 or 1).
- Use the quotient for the next division.
- Repeat until the quotient becomes 0.
- Read the remainders **bottom‑up** – this is the binary answer.
Example: Convert 156₁₀ to binary.
| Division step | 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 |
Remainders read from bottom to top give 10011100₂.
2.2.2 Largest‑Power (Subtraction) Method
- List powers of 2 up to the given number.
- Starting with the largest power ≤ the number, place a 1 and subtract that power.
- Move to the next lower power: place 1 if it fits into the remaining value, otherwise place 0.
- The sequence of 1s and 0s from highest to lowest power is the binary result.
Example: Convert 156₁₀ using the subtraction method.
| Power (2ⁿ) | Value | Place (1/0) | Remaining |
| 2⁷ | 128 | 1 | 156‑128 = 28 |
| 2⁶ | 64 | 0 | 28 |
| 2⁵ | 32 | 0 | 28 |
| 2⁴ | 16 | 1 | 28‑16 = 12 |
| 2³ | 8 | 1 | 12‑8 = 4 |
| 2² | 4 | 1 | 4‑4 = 0 |
| 2¹ | 2 | 0 | 0 |
| 2⁰ | 1 | 0 | 0 |
Result: 10011100₂ (same as the division method).
3. Negative Numbers – Two’s‑Complement
3.1 What is two’s‑complement?
- Standard method for representing signed integers in binary for the IGCSE.
- For an n‑bit word the range is
‑2ⁿ⁻¹ … 2ⁿ⁻¹‑1.
- The most‑significant bit (MSB) is the sign bit:
0 = positive, 1 = negative.
3.2 Converting a positive decimal to two’s‑complement (n bits)
- Convert the absolute value to binary (Section 2).
- Pad with leading zeros so the total length is exactly n bits.
- Invert every bit (0 → 1, 1 → 0).
- Add 1 to the inverted number (ignore any overflow beyond the n‑th bit).
Example: Represent ‑25 as an 8‑bit two’s‑complement number.
- 25 →
00011001₂ (already 8‑bit).
- Invert →
11100110₂.
- Add 1 →
11100111₂.
Thus ‑25₁₀ = 11100111₂ (8‑bit).
3.3 Converting two’s‑complement to decimal
- If the MSB is
0, treat the whole pattern as a normal positive binary number.
- If the MSB is
1:
- Invert all bits.
- Add 1.
- Interpret the result as a positive decimal and prefix a minus sign.
Example: Convert 11010110₂ (8‑bit) to decimal.
- MSB = 1 → negative.
- Invert →
00101001₂.
- Add 1 →
00101010₂ = 42₁₀.
- Result →
‑42₁₀.
3.4 Overflow in two’s‑complement arithmetic
- Overflow occurs when the true mathematical result lies outside the range
‑2ⁿ⁻¹ … 2ⁿ⁻¹‑1 for an n‑bit word.
- In addition, overflow is detected when the carry **into** the sign bit differs from the carry **out of** the sign bit.
Example (addition overflow): 8‑bit numbers 01111111₂ (127) + 00000001₂ (1).
- Binary sum =
10000000₂ (MSB = 1, interpreted as –128).
- Since the correct result 128 cannot be represented in 8 bits, overflow has occurred.
3.5 Logical Shifts and overflow
Logical shifts move bits without preserving the sign. A shift can therefore change the sign bit and cause overflow.
Left‑shift overflow example: 01111111₂ (127) << 1 → 11111110₂ = –2 (sign bit flipped). The operation has overflowed the positive range.
Right‑shift on a negative two’s‑complement number: Logical right shift inserts a 0 on the left, so the sign is lost.
- Example:
11100101₂ (‑27) >> 1 → 01110010₂ = 114₁₀, a completely different value.
- For arithmetic right shift (preserving sign) the exam expects a logical shift unless explicitly stated otherwise.
4. Binary ↔ Hexadecimal Conversion
4.1 Binary → Hexadecimal
- Pad the binary number on the left with zeros so its length is a multiple of 4.
- Group the bits into 4‑bit “nibbles”.
- Convert each nibble to its hexadecimal digit (use the table in 1.3).
Example: 1011010011₂
- Pad →
0010 1101 0011₂.
- Groups:
0010 = 2, 1101 = D, 0011 = 3.
- Result →
2D3₁₆.
4.2 Hexadecimal → Binary
- Replace each hex digit with its 4‑bit binary equivalent (see table in 1.3).
Example: 9A₁₆ → 1001 1010₂.
5. Logical Shift Operations
- Logical left shift (<<): all bits move left; a 0 is inserted at the right‑most position. Each shift multiplies the unsigned value by 2 (ignoring overflow).
- Logical right shift (>>): all bits move right; a 0 is inserted at the left‑most position. Each shift divides the unsigned value by 2 (integer division).
Example (8‑bit unsigned word): 00110101₂ (53₁₀)
- Left shift 1 place →
01101010₂ = 106₁₀.
- Right shift 2 places →
00001101₂ = 13₁₀.
Overflow note: If a shift changes the sign bit of a two’s‑complement number, the result is no longer a correct representation of the original signed value – this is considered overflow.
6. Text Representation – ASCII & Unicode
6.1 ASCII
- 7‑bit code (often stored in an 8‑bit byte) representing 128 characters: A‑Z, a‑z, digits, punctuation, and control codes.
- Each character is identified by a decimal value (0‑127) which can be written in binary or hexadecimal.
Example: The character ‘G’
- ASCII decimal = 71₁₀.
- Binary =
01000111₂.
- Hexadecimal =
47₁₆.
6.2 Unicode (UTF‑8) – exam focus
- Extends ASCII to over a million characters, using 1‑4 bytes per character.
- For the IGCSE you only need to know that the first 128 Unicode code points are identical to ASCII.
7. Storage Units & Simple File‑Size Calculations
7.1 Units of digital information
| Unit | Symbol | Bits |
| bit | b | 1 |
| byte | B | 8 |
| kilobyte | KB | 8 × 1 024 = 8 192 |
| megabyte | MB | 8 × 1 024 × 1 024 = 8 388 608 |
| gigabyte | GB | 8 × 1 024³ = 8 589 934 592 |
7.2 Example – Image file size
A colour image of 640 × 480 pixels uses 24 bits per pixel (8 bits each for Red, Green, Blue).
- Total bits = 640 × 480 × 24 = 7 372 800 bits.
- Convert to kilobytes: 7 372 800 ÷ 8 ÷ 1 024 ≈ 900 KB.
7.3 Simple lossless compression – Run‑Length Encoding (RLE)
RLE stores a character followed by the number of consecutive repetitions.
Example: AAAAABBBCCDAA → 5A3B2C1D2A. Compare the length of the compressed string with the original to discuss efficiency.
8. Common Pitfalls & Exam Tips
- Always start counting powers of 2 from
2⁰ on the right‑hand side.
- When using the division method, write each remainder clearly; a missing digit invalidates the whole answer.
- For two’s‑complement, pad to the required word length **before** inverting the bits.
- After any binary conversion, perform a quick reverse‑check (binary → decimal or hex → binary) to catch mistakes.
- Remember that leading zeros do not affect the value but are required for fixed‑length questions (e.g., 8‑bit or 16‑bit representations).
- When a logical shift changes the sign bit, note that overflow has occurred – this is a common exam trap.
- For hex‑binary work, use the 4‑bit table as a shortcut; it saves time and reduces errors.