Data Storage · Cambridge syllabus 1.3 · Lesson 2 of 3
File Size Calculations
Choose the formula for the file. An image needs its width and height in pixels and its colour depth; a sound needs its sample rate, sample resolution and length in seconds. Calculate in bits, divide by 8 for bytes, then divide by 1024 for each unit up. Calculators are not allowed, so keep the numbers as powers of 2 where you can.
By the end, you can
- Calculate the file size of an image file and of a sound file.
- Apply appropriate formulae.
- Compare storage requirements for different representations.
- Check that units are consistent before calculating.
Calculating storage requirements
Storage questions follow one pattern: work out the size of one item in bits, convert to the unit asked for, then multiply by how many there are.
The two formulas are the ones already met. Image: width × height × colour depth. Sound: sample rate × sample resolution × length in seconds.
Convert in explicit steps rather than in one jump: bits to bytes by dividing by 8, bytes to KiB by dividing by 1024, KiB to MiB by dividing by 1024 again. Most errors here are a factor of 8 in the wrong place, or 1000 used where the syllabus requires 1024, and writing each step out makes them visible.
Calculators are not allowed, so make the arithmetic easy: divide by 8 early and cancel powers of 2. An image 512 by 256 pixels with a colour depth of 8 bits is 512 × 256 × 8 bits, which is 512 × 256 bytes. Since 512 × 2 = 1024, dividing by 1024 leaves 256 ÷ 2 = 128 KiB, with no long multiplication at all.
A common question asks how many files fit on a device: convert both to the same unit, divide the capacity by the file size, and round down, because a partial file is not a file.
Give the answer in the unit the question asked for, and state it: "2.25 MiB" rather than "2359296".
Worth remembering
- One item in bits, convert, then multiply by the number of items.
- Convert in steps: ÷ 8 for bytes, then ÷ 1024 for each unit up.
- No calculator: divide by 8 early and cancel powers of 2.
- How many fit: same units, divide, and round down.
Worked example
A 64 × 64 image at 24 bits per pixel needs 64 × 64 × 24 ÷ 8 = 12288 bytes, and 12288 ÷ 1024 = 12 KiB, before headers or compression.
Practice
Warm-up · not marked
Check your understanding
Answer in your own words, then compare with the worked answer. Nothing here is saved or scored.
Worked answer
10000 × 8 × 5 = 400000 bits = 50000 bytes.
Check your method, units and explanation against it.
Marked practice
Set 1 of 4 · easiest first · Checked as you go, with the worked answer. Sign in or create a free account to save your progress.