Topic 1 · Data representation

Data storage units and file size calculations

Video lesson: Data storage units and file size calculations▶ Watch the video lessonShort, exam-focused explanation of this topic on the CS with Aamir YouTube channel.

Exam questions often ask you to calculate how much storage an image or sound file needs, and to give the answer in a particular unit. This page explains the units and both calculations with worked examples.

Data storage units

UnitSize
bita single 0 or 1
nibble4 bits
byte8 bits
kibibyte (KiB)1024 bytes
mebibyte (MiB)1024 KiB
gibibyte (GiB)1024 MiB
tebibyte (TiB)1024 GiB
pebibyte (PiB)1024 TiB
exbibyte (EiB)1024 PiB

To convert to a bigger unit, divide (by 8 to go from bits to bytes, then by 1024 for each step up). To convert to a smaller unit, multiply.

Image file size

File size (bits) = image resolution (width × height in pixels) × colour depth (bits per pixel)
Example: an image is 1024 × 768 pixels with a colour depth of 24 bits.
1024 × 768 × 24 = 18 874 368 bits
÷ 8 = 2 359 296 bytes
÷ 1024 = 2304 KiB
÷ 1024 = 2.25 MiB

A higher resolution or a greater colour depth gives a better-quality image but a larger file.

Sound file size

File size (bits) = sample rate (Hz) × sample resolution (bits) × length of the recording (seconds)
Example: a 60-second recording is sampled 44 100 times per second with a sample resolution of 16 bits.
44 100 × 16 × 60 = 42 336 000 bits
÷ 8 = 5 292 000 bytes
÷ 1024 ≈ 5168 KiB
÷ 1024 ≈ 5.05 MiB

A higher sample rate or sample resolution records the sound more accurately but makes the file larger. For a stereo recording, multiply by 2 for the two channels.

Exam tips

Want the full topic notes, slides and worksheets? See Notes & Slides, practise with the free CS with Aamir Quiz App, or order the O Level Computer Science Study Guide.