Library Computer Science 0478 Data Storage & Compression
O Level · Computer Science 0478

Data Storage & Compression

Revise Data Storage & Compression for Computer Science 0478 (O Level) — revision notes and instant AI marking. Free to start.

📖 Revision notes · preview
Cambridge IGCSE · Computer Science

Data Storage & Compression

Computers only understand 1s and 0s — this chapter is about how we measure those bits, work out how big a file will be before we even create it, and then how we shrink files down so they take up less space without (usually) losing important information.

Summary — The Whole Chapter in One Glance
  • Units of data are built from the bit upward — bit → nibble → byte → kibibyte → mebibyte → gibibyte, and so on — each one 1024× the size of the last (once you're past a byte).
  • Kilobyte ≠ Kibibyte. Kilobyte (KB) uses powers of 10 (1000), Kibibyte (KiB) uses powers of 2 (1024). Exam answers almost always want the 1024 (binary) version.
  • Converting units is just repeated multiplying or dividing by 1024 (or by 8 for bits↔bytes) — the direction depends on whether you're going up or down in size.
  • Bitmap image file size = resolution (number of pixels) × colour depth (bits per pixel).
  • Sound file size = sample rate × duration × sample resolution.
  • Compression shrinks files to save storage space, reduce bandwidth use, and cut transmission time.
  • Lossy compression permanently throws away some data — smaller files, but quality is reduced forever. Used for photos, video, music.
  • Lossless compression is fully reversible — no data is lost, just re-encoded more efficiently. Used for documents, code, anything where accuracy matters.
  • Run Length Encoding (RLE) is a lossless technique that replaces repeated ("runs" of) identical values with a shorter code showing the value and how many times it repeats.
1. Units of Data Storage

What actually is a "unit of data"?

Deep down, a computer only ever stores binary digits — 1s and 0s. A single one of these is called a bit (short for ). On its own, one bit can't say much — it can only be "on" or "off". So we group bits together into bigger and bigger chunks to represent more meaningful amounts of information, the same way we don't measure a person's height in millimetres — we group millimetres into centimetres, then metres.

UnitSymbolValue
Bitb1 or 0
Nibble4 bits
ByteB8 bits
KibibyteKiB1,024 B (2¹⁰)
MebibyteMiB1,024 KiB (2²⁰)
GibibyteGiB1,024 MiB (2³⁰)
TebibyteTiB1,024 GiB (2⁴⁰)
PebibytePiB1,024 TiB (2⁵⁰)
ExbibyteEiB1,024 PiB (2⁶⁰)

Why does a byte matter so much? A single byte (8 bits) can represent 2⁸ = 256 different values — which happens to be enough to represent every letter, number, and symbol on a standard keyboard (that's exactly why the ASCII character set fits in one byte). This makes the byte the "natural" building block computers are organised around.

Kilobyte vs Kibibyte — the exam trap

You will see two very similar-looking units and it's extremely easy to mix them up:

  • 1 kilobyte (KB) = 1000 bytes — this uses prefixes (powers of 10), the same system marketers use when they sell you a "500 GB" hard drive.
  • 1 kibibyte (KiB) = 1024 bytes — this uses prefixes (powers of 2), which is how the computer itself actually addresses memory internally.
⚠️ Why your hard drive "loses" space This mismatch is exactly why a "1 TB" hard drive shows up as roughly 931 GiB in your operating system. The manufacturer counted in decimal (1000s), but your OS displays it in binary (1024s) — no data is actually missing!

For IGCSE, unless a question specifically says "decimal" or gives you the KB/1000 system, always work in 1024s (KiB, MiB, GiB…) — this is the version the syllabus and mark schemes expect.

Converting between units

Bigger unit → smaller unit = × 1024 (or × 8 for bits/bytes) e.g. converting GiB into MiB — you're breaking one big thing into 1024 smaller pieces, so you multiply.
Smaller unit → bigger unit = ÷ 1024 (or ÷ 8 for bits/bytes) e.g. converting KiB into MiB — you're grouping 1024 small things into one bigger thing, so you divide.

Quick way to remember the direction: ask yourself "am I ending up with a bigger number or a smaller number?" If your file is 2 tebibytes and you want it in gibibytes, you know gibibytes are much smaller units, so there must be of them — multiply. If you're going from kibibytes up to mebibytes, mebibytes are a bigger unit, so there will be of them — divide.

Converting…UnitOperation
bigger → smallerBitMultiply by 8 ⇑ / Divide by 8 ⇓
smaller → biggerByte
Kibibyte, Mebibyte, Gibibyte, Tebibyte, Pebibyte, ExbibyteMultiply by 1024 ⇑ / Divide by 1024 ⇓
Practice Question 1

Convert 1 PiB to GiB.

Practice Question 2

A file is 2000 KiB. Convert this to MiB, and separately convert 24 bits to bytes.

2. Calculating File Sizes

Bitmap image file size

A bitmap image is just a huge grid of coloured squares called pixels. Each pixel needs some number of bits to store its colour — the more bits you give it, the more possible colours it can be (this is called the colour depth). To work out the total file size, you just need to know how many pixels there are, and how many bits each one costs.

Image file size = Resolution × Colour Depth Resolution = total number of pixels = image width × image height. Colour depth = bits used per pixel.

So really there are two equivalent formulas — pick whichever the question gives you numbers for:

Image file size = Image width × Image height × Colour Depth
Worked Example

An image is 500 pixels wide, 500 pixels tall, with a colour depth of 24 bits. What is the file size in KiB?

Practice Question

An image has a resolution of 800 × 600 pixels and a colour depth of 8 bits. Calculate the file size in KiB.

Sound file size

Digital audio is recorded by "sampling" the sound wave thousands of times per second — imagine taking a tiny snapshot of the wave's height at regular intervals and writing down the number each time. Three things control the file size: how you sample (sample rate), how you record for (duration), and how much you store per sample (sample resolution).

Sound file size = Sample Rate × Duration × Sample Resolution Sample rate = samples taken per second. Duration = length of recording in seconds. Sample resolution = bits stored per sample.
Worked Example

A sound is recorded at a sample rate of 100 samples/second for 60 seconds, with a sample resolution of 24 bits. Find the file size in KiB.

💡 Spot the pattern Notice both formulas follow the exact same "recipe": (how much data) × (how detailed each unit is), then convert bits → bytes (÷8) → KiB (÷1024). Once you see this pattern, you never need to memorise the formulas separately again.
3. The Need for Compression

Why do we compress files at all?

Compression means reducing the size of a file so it takes up less space on secondary storage (like a hard drive or SSD). Think about how many photos, songs, and videos you have on your phone — without compression, you'd run out of storage almost instantly, and sending even one photo over the internet would take forever.

Compression gives us three big wins:

  • Less storage space required — you can fit more files on the same device.
  • Less bandwidth required — smaller files use less of your internet connection's capacity.
  • Shorter transmission time — smaller files upload/download/transfer faster.

There are two completely different strategies for compressing a file, and the exam expects you to know exactly how they differ: lossy and lossless.

4. Lossy Compression

What is lossy compression?

Lossy compression makes a file smaller by permanently throwing some data away. Once it's gone, it's gone — you can never get the file back to its exact original state. This sounds bad, but it's actually a smart trade-off: for things like photos, video and music, our eyes and ears often can't detect the difference anyway, so we can lose a lot of data before anyone notices.

A classic example: in a photograph, lossy compression looks for similar colours sitting near each other and merges them into a single colour, reducing the total number of unique colours stored — the human eye usually can't spot the difference, but the file becomes dramatically smaller.

PropertyLossy Compression
Reversible?❌ No — irreversible
File size reduction✅ Very large
Quality impact❌ Reduced / degraded
Best used forPhotos, video, music/sound
📸 Real numbers example from the chapter Original JPG photo: 824 KB. After 50% lossy compression: 76 KB. After 80% lossy compression: just 38 KB. That's over a 95% reduction — and to the naked eye, the images still look nearly identical!
Practice Question

Why is lossy compression a sensible choice for compressing photos taken on a smartphone, but a poor choice for compressing a spreadsheet of financial data?

5. Lossless Compression

What is lossless compression?

Lossless compression shrinks a file by encoding the data more cleverly — finding smarter, shorter ways to represent exactly the same information — rather than deleting any of it. When you "decompress" (open) the file, the original data is rebuilt perfectly, bit for bit. Nothing is missing.

The trade-off is that lossless compression usually can't shrink a file as much as lossy compression can, because it's not allowed to throw anything away. It's more suitable for data where accuracy is essential — documents, program code, spreadsheets — where losing even one character could break everything.

PropertyLossless Compression
Reversible?✅ Yes — fully reversible
File size reduction⚠️ Smaller reduction than lossy
Quality impact✅ None — perfect original restored
Best used forDocuments, text files, program files
📄 Real numbers example from the chapter A DOCX document at 507 KB is losslessly compressed into a PDF at 108 KB — smaller, but every single word and character comes back perfectly when opened. Nothing was lost, just re-encoded more efficiently.

Run Length Encoding (RLE)

RLE is one specific lossless algorithm you need to know in detail. It works by scanning data for runs — sequences where the exact same value repeats over and over — and replacing each run with just two pieces of information: the repeated value is, and it repeats.

RLE encodes: (value) + (count of consecutive repeats) Instead of storing the same value 100 times in a row, you just store "this value, repeated 100 times" — one short code instead of 100 repeated entries.

Text example:

AAAABBBCCDAA → 4A3B2C1D2A Broken down: four A's, three B's, two C's, one D, two A's.

Image example: RLE is especially powerful for bitmap images that contain large blocks of a single flat colour — like a cartoon drawing, a logo, or a scanned document with big white backgrounds. A row of pixels with 5 red pixels followed by 3 blue pixels could be represented as simply 5R3B instead of storing all 8 individual pixel values.

⚠️ When RLE doesn't help RLE only works well when there's lots of repetition. A photo of a busy, colourful scene (where almost every pixel is a slightly different colour) has very few "runs", so RLE barely shrinks the file at all — sometimes it can even make the file bigger! This is why RLE suits simple, flat-colour images and text far better than photographs.
Practice Question

Use Run Length Encoding to compress the string: WWWWWBBBBGGGGGGY

What to Memorise
Bit
A single binary digit — 1 or 0. The smallest unit of data.
Nibble
4 bits.
Byte
8 bits — enough to store one character (e.g. in ASCII).
1024 rule
Every unit above a byte is 1024× the size of the one below it (KiB → MiB → GiB → TiB → PiB → EiB).
KB vs KiB
KB = 1000 bytes (decimal). KiB = 1024 bytes (binary). IGCSE uses the binary (1024) system by default.
Image size formula
Resolution × Colour Depth, or Width × Height × Colour Depth.
Sound size formula
Sample Rate × Duration × Sample Resolution.
Compression
Reducing a file's size — saves storage, saves bandwidth, speeds up transmission.
Lossy compression
Irreversible — permanently deletes some data. Big size reduction, lower quality. Used for photos/video/audio.
Lossless compression
Reversible — re-encodes data with nothing lost. Smaller reduction, perfect quality. Used for documents/text/code.
Run Length Encoding (RLE)
A lossless method that replaces repeated ("run") values with a value + count, e.g. AAAA → 4A.
Colour depth
The number of bits used to store the colour of one pixel — more bits = more possible colours.
Concepts Checklist
Exam Tips
🚫 Common mistake #1 — Forgetting to convert units mid-calculation File size formulas give you an answer in bits first. Students often forget the final steps: divide by 8 to get bytes, then divide by 1024 (possibly more than once) to reach KiB/MiB. Always check what unit the question actually wants your final answer in.
🚫 Common mistake #2 — Mixing up multiply and divide when converting Before converting, always ask: "is the unit I'm converting TO bigger or smaller than the one I have?" Going to a bigger unit = divide. Going to a smaller unit = multiply. Don't just guess based on which direction feels right.
🚫 Common mistake #3 — Saying lossy compression is "always bad" Examiners want you to recognise lossy compression as a smart, deliberate trade-off — not just a downside. If asked to justify using lossy compression, mention BOTH that the file size drops significantly AND that the quality loss is often unnoticeable to humans, for full marks.
✅ Mark scheme tip — "Explain" questions need TWO parts Just like the worked example in this chapter (explain two reasons lossy compression is beneficial), examiners usually award one mark for stating a fact, and a second mark for explaining that fact matters. E.g. "Lossy decreases file size [1] ...so it can be sent via email quicker [1]" — always follow up your point with its consequence.
✅ Mark scheme tip — Show your working for calculations For file size questions, examiners give marks for each correct step (e.g. calculating resolution, multiplying by colour depth, converting units) — not just the final number. Even if your final answer is wrong, you can pick up method marks by clearly showing each stage.
🔓 Read the full Data Storage & Compression note — free You're seeing the preview · free account, no card needed
What's inside
📖 Revision notes 🎯 Learn mode ✦ AI flashcards ✓ Instant AI marking 🧊 3D explorers 🧪 Experiments & simulations 📈 Progress tracking
📄 Practise Data Storage & Compression with Computer Science 0478 past papers Every paper with its mark scheme — answer online, marked instantly. Open →

Read the full Data Storage & Compression notes free

That's the preview — create a free account to read the rest, plus flashcards and practice questions with instant AI marking. No credit card.

Unlock the full notes free →

More Computer Science topics