← Back to CS Hub
Topic 2 — Paper 1

Data Representation

Binary, hexadecimal, images, sound & compression — understand how computers store and process data.

0
Activities
0
Correct
0
Streak

📖 Core Theory

Key definitions, concepts, and terminology for Topic 2

🔑
Key Definitions
Bit
The smallest unit of data, a single binary digit (0 or 1).
Nibble
4 bits.
Byte
8 bits.
Binary
Base-2 number system using 0 and 1.
Denary
Base-10 number system (everyday counting).
Hexadecimal
Base-16 using 0–9 and A–F.
ASCII
Character encoding using 7 bits, 128 characters.
Unicode
Extended character encoding supporting all world languages, up to 32 bits.
Pixel
A single point/dot in a digital image.
Resolution
The number of pixels in an image (width × height).
Colour Depth
Number of bits used to represent the colour of each pixel.
Sample Rate
Number of samples taken per second, measured in Hz.
Bit Depth
Number of bits per sample in digital sound.
Lossy Compression
Permanently removes data to reduce file size; some quality is lost.
Lossless Compression
Reduces file size without losing any data; original can be perfectly restored.
Run-Length Encoding (RLE)
Lossless compression that replaces repeated consecutive values with a count and value.
🌎
Real-World Examples & Analogies
💡 Why Binary? — The Light Switch Analogy

Computers use binary because transistors (tiny electronic switches) can only be ON (1) or OFF (0) — just like a light switch. There is no “half on”. With 1 switch you get 2 states. With 2 switches, you get 4 combinations (00, 01, 10, 11). With 8 switches (1 byte), you get 256 combinations — enough to represent every letter, digit, and symbol you need.

Number of BitsCombinations (2n)
1 bit2 values
2 bits4 values
3 bits8 values
4 bits (nibble)16 values
8 bits (byte)256 values
Key Point

Every piece of data inside a computer — text, images, sound, video, programs — is ultimately stored as patterns of 0s and 1s. The more bits you use, the more different values you can represent: 2n possible values for n bits.

🔢 Hexadecimal — Shorthand for Humans

Imagine trying to remember a phone number that’s 32 digits long — that’s what a binary colour code looks like! Hex condenses every 4 binary digits into a single character. So instead of writing 11111111 00000000 00000000 for pure red, you write FF0000.

Web developers use hex colour codes every day:

#FF0000 = Red #00FF00 = Green #0000FF = Blue
Key Point

Each hex digit = exactly 4 binary digits (a nibble). Two hex digits = 1 byte. This is why hex is used for MAC addresses, colour codes, memory addresses, and error codes.

🖼️ How Images are Stored — The Mosaic Analogy

A digital image is like a mosaic made of tiny coloured tiles (pixels). Resolution = how many tiles there are (more tiles = more detail = bigger file). Colour depth = how many paint colours you have available:

Colour DepthColours AvailableExample
1-bit2Black & white
8-bit256GIF images
24-bit16.7 millionTrue colour (photos)

Walkthrough — Calculate the file size of a 1920×1080 image at 24-bit colour:

Step 1:  Total pixels    = 1920 × 1080 = 2,073,600 pixels
Step 2:  Total bits      = 2,073,600 × 24 = 49,766,400 bits
Step 3:  Convert to bytes = 49,766,400 ÷ 8 = 6,220,800 bytes
Step 4:  Convert to KB   = 6,220,800 ÷ 1024 = 6,075 KB
Step 5:  Convert to MB   = 6,075 ÷ 1024 ≈ 5.93 MB
Key Point

Increasing resolution OR colour depth increases file size. This is why compression is essential — a raw 4K photo would be over 24 MB!

🔊 How Sound is Stored — The Flipbook Analogy

Recording digital sound is like making a flipbook of a wave. The sample rate is how many “snapshots” you take per second (CD quality = 44,100 per second). The bit depth is how precisely you measure each snapshot (16-bit CD quality = 65,536 possible values). More snapshots + more precision = better quality but bigger file.

Walkthrough — Calculate file size for 3 minutes of CD-quality stereo audio:

Sample rate:  44,100 Hz
Bit depth:    16 bits
Channels:     2 (stereo)
Duration:     3 min = 180 seconds

Step 1:  Total bits  = 44,100 × 16 × 2 × 180 = 254,016,000 bits
Step 2:  Bytes       = 254,016,000 ÷ 8 = 31,752,000 bytes
Step 3:  MB          = 31,752,000 ÷ 1024 ÷ 1024 ≈ 30.3 MB
Key Point

This is why MP3 compression exists — it reduces 30 MB to about 3–4 MB by removing frequencies humans can barely hear (lossy compression).

📋 Lossy vs Lossless — The Photocopy Analogy

Lossless compression is like zipping a folder — when you unzip it, everything is exactly the same. Lossy is like photocopying a photocopy — each copy loses a tiny bit of detail, and you can never get the original back.

TypeHow It WorksFormatsBest For
LossyPermanently removes data humans won’t noticeJPEG, MP3, MPEGPhotos, music, video
LosslessFinds patterns to store data more efficientlyZIP, PNG, FLACText, code, medical images
Key Point

Lossy gives smaller files but you lose quality permanently. Lossless gives larger files but the original data is perfectly preserved. Choose based on whether quality loss matters.

📊 Run-Length Encoding (RLE) Walkthrough

RLE works on data with lots of repeated consecutive values. It replaces runs of the same value with a count and the value.

Example: AAABBBCCCCDD becomes 3A3B4C2D. That’s 12 characters compressed to 8.

Encoding walkthrough:

Original:   W W W W W B B B W W W W W W W W
Count:      5 × W       3 × B   8 × W
Encoded:    5W 3B 8W

16 characters → 6 characters  (62.5% reduction!)

Decoding walkthrough:

Encoded:    4R 2G 5B
Decoded:    R R R R G G B B B B B
Result:     RRRRGGBBBBB
Key Point

RLE is great for simple images with large blocks of the same colour (pixel art, diagrams, logos), but terrible for photographs where every pixel is different — it can actually make the file larger!

💡
Key Points
Key Point

Units of data storage: 1 byte = 8 bits, 1 KB = 1024 bytes, 1 MB = 1024 KB, 1 GB = 1024 MB, 1 TB = 1024 GB.

Key Point

Hexadecimal is used because it's more human-readable than binary. Each hex digit represents exactly 4 binary digits (a nibble).

🔢
Number Base Conversions
Binary to Denary Conversion

Place values: 128, 64, 32, 16, 8, 4, 2, 1

Method: Write out the place values. Place the binary digits underneath. Add up the place values where there is a 1.

Example: 10110011

1286432168421
10110011

128 + 32 + 16 + 2 + 1 = 179

Denary to Binary Conversion

Method (Repeated Division by 2): Divide the denary number by 2 repeatedly. Record the remainder each time. Read the remainders from bottom to top.

Alternative (Place Value Method): Start from the left (128). If the place value fits into the remaining number, write 1 and subtract it. Otherwise write 0. Move to the next place value.

Example: Convert 179 to binary

179 ≥ 128? Yes → 1 (remaining: 51)

51 ≥ 64? No → 0

51 ≥ 32? Yes → 1 (remaining: 19)

19 ≥ 16? Yes → 1 (remaining: 3)

3 ≥ 8? No → 0

3 ≥ 4? No → 0

3 ≥ 2? Yes → 1 (remaining: 1)

1 ≥ 1? Yes → 1 (remaining: 0)

Result: 10110011

Hexadecimal to Binary/Denary

Hex to Binary: Split each hex digit into a 4-bit nibble.

Example: B3

B = 11 in denary = 1011 in binary

3 = 3 in denary = 0011 in binary

B3 = 10110011

Hex to Denary: Multiply each digit by its place value (16¹, 16&sup0;).

B3 = (11 × 16) + (3 × 1) = 176 + 3 = 179

Key Point

Hex values: A=10, B=11, C=12, D=13, E=14, F=15. Each hex digit maps directly to one nibble (4 bits).

Binary Addition Rules

Rules:

0 + 0 = 0

0 + 1 = 1

1 + 0 = 1

1 + 1 = 10 (write 0, carry 1)

1 + 1 + 1 = 11 (write 1, carry 1)

Worked Example — Add 01101011 (107) + 00110101 (53):

  Carry:    1 1 1 1 1
            0 1 1 0 1 0 1 1   (107)
          + 0 0 1 1 0 1 0 1   ( 53)
          ——————————————————————
          = 1 0 1 0 0 0 0 0   (160)  ✔

Work from right to left. When 1+1 = 10, write 0 and carry 1 to the next column. When 1+1+1 = 11, write 1 and carry 1.

Overflow Example:

            1 1 1 1 1 1 1 1   (255)
          + 0 0 0 0 0 0 0 1   (  1)
          ——————————————————————
          1 0 0 0 0 0 0 0 0   (256 — needs 9 bits!)
          ↑
    This 9th bit is lost — the computer stores 00000000 (0) — WRONG!
Key Point

Overflow occurs when the result of a binary addition exceeds the available number of bits (e.g., two 8-bit numbers produce a 9-bit result). The extra bit is lost, giving an incorrect answer. If adding two 8-bit numbers gives a 9th bit, the computer truncates it — the result wraps around and is wrong.

📸
Images & Sound
Image File Size Formula

Formula: File size (bits) = width × height × colour depth

To convert to bytes, divide by 8. To convert to KB, divide by 1024. To convert to MB, divide by 1024 again.

Example: A 1920 × 1080 image with 24-bit colour depth:

1920 × 1080 × 24 = 49,766,400 bits

49,766,400 ÷ 8 = 6,220,800 bytes

6,220,800 ÷ 1024 = 6,075 KB

6,075 ÷ 1024 ≈ 5.93 MB

Key Point

Increasing resolution or colour depth increases the file size. Higher colour depth = more colours available. Higher resolution = more detail but bigger file.

Sound File Size Formula

Formula: File size (bits) = sample rate × bit depth × duration (seconds)

To convert to bytes, divide by 8.

Example: A 30-second clip at 44,100 Hz sample rate with 16-bit depth:

44,100 × 16 × 30 = 21,168,000 bits

21,168,000 ÷ 8 = 2,646,000 bytes

2,646,000 ÷ 1024 ≈ 2,583.98 KB

2,583.98 ÷ 1024 ≈ 2.52 MB

Key Point

Higher sample rate = more samples per second = better quality sound but larger file. Higher bit depth = more levels of amplitude = better quality but larger file.

🔍 Explore & Calculate

Interactive converters and calculators for data representation

🔃
Binary ↔ Denary ↔ Hex Converter

Type in any field to convert between number bases (8-bit: 0–255).

Binary Addition Practice

Add the two 8-bit binary numbers. Enter your answer below.

Carry:
A:
B:
Sum:
🖼
Image File Size Calculator

Enter the image dimensions and colour depth to calculate the file size.

🎵
Sound File Size Calculator

Enter the recording properties to calculate the file size.

🧩 Guided Practice

Apply your knowledge with hints available

📂
Categorise: Lossy vs Lossless Compression

Drag each item into the correct category.

Items to sort:

✏️
Fill in the Blanks: Binary Conversion

Convert denary 179 to binary using the place value method. Fill in each bit. Click the hint button if you get stuck.

🔢
Order the Steps: RLE Encoding

Drag the steps into the correct order for Run-Length Encoding.

Available Steps

Correct Order

🧠 Retrieval Practice

Test your memory by matching terms with definitions

🃏
Memory Match

Find all 8 matching pairs. Click two cards to flip them.

📝 Exam Practice

Build answers using sentence banks, then reveal the mark scheme

⚡ Challenge

No hints, no help — prove your mastery

Time Remaining:
5:00

📊 Performance Review

See how you performed across each sub-topic

Overall Performance

0%

Complete activities to see your results