Syllabus & Goals 3 min
Cambridge 1.3 · Data storage and file compression Paper 1 · Computer Systems
By the end of this lesson you can:
- State the units of storage from bit to PiB using the IEC system.
- Calculate the file size of a bitmap image.
- Calculate the file size of a sound sample.
Recap / Warm-Up 5 min
Last lesson you saw that higher resolution and colour depth make bigger files. Now we put numbers to it.
Quick starter
How many bits are there in one byte? How many bytes in a nibble?
Reveal the answer
1 byte = 8 bits. A nibble is 4 bits — half a byte. Every file size starts from these.
Key Concept 14 min
1 · Units of storage (IEC)
A bit is a single 0 or 1. A nibble is 4 bits and a byte is 8 bits. Because memory is built in powers of 2, the syllabus uses the IEC units, where each step is × 1024 (2¹⁰):
| Unit | Symbol | Number of bytes |
|---|---|---|
| kibibyte | KiB | 2¹⁰ = 1 024 |
| mebibyte | MiB | 2²⁰ = 1 048 576 |
| gibibyte | GiB | 2³⁰ |
| tebibyte | TiB | 2⁴⁰ |
| pebibyte | PiB | 2⁵⁰ |
2 · The two formulas
Both formulas give an answer in bits. Divide by 8 for bytes, then by 1024 for each unit step (KiB → MiB → GiB).
Worked Example 12 min
(a) Image: 2048 × 2048 pixels, colour depth 16 bits — size in MiB?
- Total pixels = 2048 × 2048 = 4 194 304
- Bits = 4 194 304 × 16 = 67 108 864 bits
- Bytes = 67 108 864 ÷ 8 = 8 388 608 bytes
- MiB = 8 388 608 ÷ (1024 × 1024) = 8 MiB
(b) Sound: 44 100 Hz, 16-bit, 60 min, stereo — size in MiB?
- Bits = 44 100 × 16 × (60 × 60) = 2 540 160 000
- Stereo ×2 = 5 080 320 000 bits
- Bytes = 5 080 320 000 ÷ 8 = 635 040 000
- MiB = 635 040 000 ÷ (1024 × 1024) ≈ 605 MiB
The image calculation as code
Cambridge pseudocode
// Work out the size of a bitmap image DECLARE Width, Height, ColourDepth : INTEGER DECLARE Bits, Bytes : INTEGER Width ← 2048 Height ← 2048 ColourDepth ← 16 Bits ← Width * Height * ColourDepth Bytes ← Bits DIV 8 OUTPUT "Image size in bytes: ", Bytes
The same calculation in Python (IDLE)
# File size of a bitmap image, converted to MiB width = 2048 height = 2048 colour_depth = 16 bits = width * height * colour_depth size_bytes = bits // 8 size_mib = size_bytes / (1024 * 1024) print("Image is", size_mib, "MiB")
Output
Image is 8.0 MiB
Try It Yourself 12 min
Goal: How many bytes are there in 4 KiB? Show the power of 2 or the multiplication.
Hint: 1 KiB = 1024 bytes.
Goal: An image is 1024 × 768 pixels with a colour depth of 24 bits. Calculate its size in bytes.
Hint: pixels × colour depth gives bits; then ÷ 8.
Goal: A 30-second mono sound is sampled at 44 100 Hz using 8 bits. Calculate the file size in MiB.
📝 Exam Practice 10 min
State how many bits are in one nibble.
Mark scheme
- 4 bits (1).
An image is 16 384 pixels wide and 512 pixels high, with a colour depth of 8 bits. Calculate its size in mebibytes (MiB).
Mark scheme
- Pixels × depth = 16 384 × 512 × 8 = 67 108 864 bits (1).
- ÷ 8 = 8 388 608 bytes (1).
- ÷ (1024 × 1024) =
8 MiB(1).
Describe the effect on the file size of increasing an image's colour depth, and explain why.
Mark scheme
- The file size increases (1).
- Because more bits are used to store each pixel (1).
Recap & Key Terms 3 min
Storage is measured in IEC units that step up by 1024 (KiB, MiB, GiB…). An image's size is resolution × colour depth; a sound's size is sample rate × resolution × seconds (× 2 for stereo). Both give bits — divide by 8 for bytes, then by 1024 per unit.
- Bit / nibble / byte
- 1 bit is a single 0 or 1; a nibble is 4 bits; a byte is 8 bits.
- Kibibyte (KiB)
- 1024 bytes (2¹⁰) — the IEC unit one step above a byte.
- Image file size
- Resolution (pixels) × colour depth (bits).
- Sound file size
- Sampling rate × sampling resolution × seconds (× 2 for stereo).
Homework 1 min
Task (≤ 15 min): A photo is 1920 × 1080 pixels with a colour depth of 24 bits. Calculate its size in (a) bytes and (b) MiB (to 1 decimal place).
Model answer
- Bits = 1920 × 1080 × 24 = 49 766 400
- (a) Bytes = 49 766 400 ÷ 8 = 6 220 800 bytes
- (b) MiB = 6 220 800 ÷ 1 048 576 ≈ 5.9 MiB