top of page

Chapter 1: Data Representation

Learn how data is stored, processed, and represented in a computer.

1.1 Number Systems

 

1.1.1 Binary, Denary, and Hexadecimal

Computers use Binary (Base-2) because they are made of transistors (switches) that only have two states: ON (1) or OFF (0). Humans use Denary (Base-10), but programmers use Hexadecimal (Base-16) as a "shorthand."

📖 How to Convert: The 8-Bit Method

Before you jump into the games, remember the Place Value Grid. To convert any number, simply place a '1' in the columns you need to add up to your target number.

 

🎮 Interactive Lab: The Base-2 Challenge

Use the simulators below to practice converting between Denary (Human) and Binary (Machine) numbers.

Exam Goal: Master the 8-bit place value grid without using a calculator!

Why use Hexadecimal? (Base-16)

In your exam, you will be asked why programmers use Hex instead of Binary. Memorize these three "E"s:

  • Easier to Read: A single Hex digit represents a 4-bit nibble, making long strings much shorter (e.g., FF instead of 11111111).

  • Error Reduction: Because the codes are shorter, programmers are less likely to make mistakes when typing or reading them.

  • Easier to Debug: It is significantly faster for a human to spot a mistake in a Hex memory dump than in a sea of 1s and 0s.

💡 Exam Tip: Never say Hex is "faster for a computer to process." It isn't! Computers still convert it to binary. Hex is strictly for human efficiency.

Real-World Applications

You must be able to identify these four specific uses of Hexadecimal in the IGCSE:

  1. MAC Addresses: Unique 48-bit hardware identifiers (e.g., 00-15-E9-2B-99-3C).

  2. HTML Color Codes: Used in CSS to represent RGB values (e.g., #FF5733).

  3. IPv6 Addresses: The new internet protocol that uses Hex to provide more addresses than IPv4.

  4. Memory Dumps: Displaying the contents of the CPU's RAM in Assembly Language or Machine Code.

Level 1: The Hex Alphabet

Instruction: Before using the Mix & Match game on the right, memorize the "Bridge" values. After 9, we switch to letters to keep each value to a single character.

Level 2: Binary ↔ Hexadecimal

The Method:

  1. Split the 8-bit binary string into two 4-bit nibbles.

  2. Convert each nibble into its Hex value.

  3. Combine them. (e.g., 1010 | 1100 becomes A | C → AC).

Level 3: Denary ↔ Hexadecimal

The Quick Math:

  • To Hex: Divide the Denary by 16. The Quotient (how many times it fits) is the first digit. The Remainder is the second digit.

  • To Denary: Multiply the first Hex digit by 16 and add the second digit.

1.1.2 Negative Numbers & Errors

Two’s Complement (Signed Integers)

In the exam, you will be asked how a computer represents negative integers. We use a system called Two's Complement.

The Modified Place Value Grid

In an 8-bit register using Two's Complement, the Most Significant Bit (the far-left column) is no longer 128. It becomes -128. All other columns remain positive.

  • Rule: If a binary number starts with 1, it is negative.

  • Rule: If it starts with 0, it is a standard positive number.

Method 1: Converting Binary to Negative Denary

To find the value of a Two's Complement string, simply add the column values together, starting with the negative -128.

Example Calculation for 11111011:

  • Grid: (-128) + 64 + 32 + 16 + 8 + 2 + 1

  • Result: -5

Method 2: Converting Negative Denary to Binary

If the exam asks you to turn a negative number (e.g., -14) into binary, use the "Flip and Add 1" shortcut:

  1. Write the positive version in binary: $14 = 00001110$.

  2. Flip all bits: Change 0s to 1s and 1s to 0s ($11110001$).

  3. Add 1 to the result: $11110001 + 1 = 11110010$.

💡 Exam Tip: Always show all three steps in your working. Examiners often give "working marks" even if your final addition is slightly off.

1.1.3 Binary Addition

 
The 4 Rules of Binary Addition

When adding two binary numbers, you only need to remember four simple outcomes:

  1. 0 + 0 = 0

  2. 0 + 1 = 1

  3. 1 + 1 = 0 (Write 0, carry 1)

  4. 1 + 1 + 1 = 1 (Write 1, carry 1)

Overflow Errors

An Overflow Error occurs when the result of a binary addition is too large to fit into the allocated number of bits (usually an 8-bit register).

  • How to spot it: If you add two 8-bit numbers and a 9th bit is generated at the far left, that bit has "overflowed."

  • The Result: The computer usually ignores the 9th bit because there is no physical "slot" for it. This makes the final stored number mathematically incorrect.

  • Syllabus Definition: If asked why an error occurred, state: "The result exceeded the maximum value that could be represented by the 8-bit register."

Binary Shifts

1.1.4 Logical Binary Shifts

Your current structure for shifts is excellent. To ensure full syllabus coverage, use this refined text for your bullet points:

1. Left Shift (Multiplication)
  • Effect: Every place you move to the left multiplies the number by 2.

    • 1 place left = times 2

    • 2 places left = times 4

    • 3 places left = times 8

  • Rule: Vacant spaces on the right are filled with 0.

  • Danger: If a '1' falls off the left edge, it causes an Overflow Error, and the result will be incorrect.

2. Right Shift (Division)
  • Effect: Every place you move to the right divides the number by 2.

  • Rule: Vacant spaces on the left are filled with 0.

  • Danger: If a '1' falls off the right edge, it results in Loss of Precision. The fractional part is lost because bit positions cannot store decimals.

1.2.1 Character Sets: ASCII vs. Unicode

A Character Set is a list of characters (letters, numbers, symbols) and the unique binary codes used to represent them.

What students MUST know for the exam:
1. ASCII
  • The Size: Originally used 7 bits (128 characters), but most systems use 8 bits (Extended ASCII).

  • The Limit: It can only represent English letters, numbers, and basic symbols. It cannot handle emojis or foreign languages like Mandarin or Arabic.

  • The Advantage: It takes up very little storage space (only 1 byte per character).

2. Unicode
  • The Size: Usually uses 16 bits or 32 bits per character.

  • The Reach: It was designed to represent every character in every language in the world, plus emojis.

  • The Advantage: It is universal. A Unicode file will display correctly on any computer in any country.

  • The Disadvantage: It takes up significantly more storage space than ASCII because it uses more bits per character.

The "Compatibility" Fact (Important!)

Students often forget this: Unicode is backwards compatible with ASCII. This means the first 128 codes in Unicode are exactly the same as the codes in ASCII.

1.2.2 Representing Sound

Sound is naturally analogue (continuous). To store it on a computer, it must be converted into digital (discrete) binary through a process called sampling.

  • Sampling: This involves measuring the amplitude of the sound wave at regular time intervals.

  • Sample Rate: The number of samples taken per second, measured in Hertz (Hz).

  • Sample Resolution (Bit Depth): The number of bits used to represent each sample amplitude.

The Quality vs. Size Trade-off
  • Increasing Sample Rate: Captures sound more accurately and captures higher frequencies, but increases file size because more data points are stored.

  • Increasing Sample Resolution: Provides a greater dynamic range and more accurate volume levels, but increases file size because more bits are used per sample.

The Sound File Size Formula

In the exam, you might be asked to calculate the size of a sound file. Use this simple formula:

File Size = Sample Rate (Hz) x Sample Resolution (bits) x Time (seconds)

To convert the final answer into Bytes, simply divide the result by 8.

1.2.3 Representing Images

Digital images are made of Pixels (short for "Picture Elements"). A pixel is the smallest unit of a digital image. When thousands of pixels are placed together, they form a complete picture.

The Three Key Factors
  • Resolution: The number of pixels that make up an image (e.g., width x height). The higher the resolution, the more detail the image has, but the larger the file size.

  • Color Depth: The number of bits used to represent the color of a single pixel.

    • 1-bit depth = 2 colors (Black and White)

    • 2-bit depth = 4 colors

    • 8-bit depth = 256 colors

    • 24-bit depth = 16.7 million colors ("True Color")

  • Metadata: This is "data about data." It is stored at the start of the file and tells the computer how to reconstruct the image. Examples include:

    • Width and Height (Resolution)

    • Color Depth

    • File Format (e.g., JPEG, PNG)

    • Date and Time of the photo

    • GPS location​​

The Math: Calculating File Size

For the exam, you must be able to calculate how many bits are in an image.

The Formula: Resolution (Width x Height) x Color Depth = File Size in Bits

Example: An image is 100 pixels wide and 50 pixels high with an 8-bit color depth.

  • Calculation: 100 x 50 x 8 = 40,000 bits.

  • To get Bytes: 40,000 / 8 = 5,000 Bytes.

The Grade 9 "Trade-Off"

Examiners will often ask you about the impact of increasing quality. Remember this rule:

  1. If you increase Resolution or Color Depth:

    • The image quality increases (more detail/more colors).

    • The file size increases significantly.

  2. The Impact of Large Files:

    • Requires more storage space (Hard Drive/Cloud).

    • Takes longer to transmit (download/upload) over a network.

    • Requires more processing power to render.

1.3 Data Storage and File Compression

​1.3.1 Data Storage Units

Computers use billions of tiny switches called transistors to store data. To measure how much data we are storing, we use a specific hierarchy of units.

The Fundamental Units
  • Bit: The smallest unit of data, representing a single 0 or 1.

  • Nibble: A group of 4 bits.

  • Byte: A group of 8 bits. This is the standard unit used to measure a single character of text.

The IGCSE Hierarchy (Smallest to Largest)

In your exam, you must use the Binary (IEC) system, which increases by powers of 2 ($2^{10} = 1024$) rather than the Metric system (1000).

Golden Rules for Exam Conversions
1. The 1024 vs 1000 Trap
  • The Rule: Always check the units in the question. If you see the "i" (KiB, MiB, GiB), you must use 1024 for your calculations.

  • Why? Computers address memory in binary. 1024 represents this binary reality ($2^{10}$), whereas 1000 is used for the SI (Metric) system.

2. The 8-Bit Bridge

The only time you do not use 1024 is when converting between Bits and Bytes.

  • Bytes to Bits: Multiply by 8.

  • Bits to Bytes: Divide by 8.

💡 Exam Tip: When converting from a large unit (like GiB) to a smaller unit (like MiB), Multiply. When converting from small to large, Divide.

data units.png

1.3.2. Data Compression

Because sound and image files can be very large, we use Compression to reduce file sizes. This saves storage space and allows for faster transmission (uploading/downloading) over the internet.

Lossy Compression
  • How it works: It permanently deletes data that the human ear or eye is unlikely to notice. This is based on Human Perception (e.g., removing sounds a human cannot hear or colors a human cannot distinguish).

  • Pros: Dramatically reduces the file size (much more than Lossless).

  • Cons: Some quality is lost, and the original data cannot be recovered.

  • File types: MP3, JPEG, MP4.

Lossless Compression
  • How it works: It reduces the file size by finding and grouping patterns in the data without losing any information.

  • The Technical Secret (RLE): One common method is Run Length Encoding (RLE). Instead of storing "Red, Red, Red, Red," it stores "4 x Red."

  • Pros: No loss of quality; the file can be returned to its original state perfectly.

  • Cons: The file size is not reduced as much as with Lossy.

  • File types: PNG, ZIP, FLAC, PDF.

© 2026 The CS Lab | [Legal & Privacy Information] The CS Lab is an independent resource. iGCSE is a registered trademark of Cambridge University Press & Assessment. This site is not affiliated with, endorsed by, or connected to any official exam board.

bottom of page