Data storage and compression

Computer Science · Data representation. The idea in plain words, the rules to remember, the mistake to avoid and a worked example, written and checked by Mega Lecture.

Test this topic freeAll Computer Science topics

The idea

The smallest unit of data is the bit, a single 1 or 0. Larger units are built up in steps of 1024, because 1024 is 210.

You can work out a file size from what the file holds. An image stores one colour code for every pixel. A sound file stores one value for every sample. Find the size in bits first, then divide to change the unit.

Compression makes a file smaller so it needs less storage, less bandwidth and less time to send. Lossy compression removes data for ever. Lossless compression loses nothing, so the original file can be rebuilt exactly.

Rules to remember

Common mistake

Students forget to divide by 8 and give the answer in bits when the question asks for bytes. Always check which unit is asked for.

Worked example

An image is 2048 pixels wide and 1024 pixels high with a colour depth of 24 bits. What is its file size in MiB?

  1. Size in bits = 2048 × 1024 × 24 = 50 331 648 bits.
  2. Bytes = 50 331 648 ÷ 8 = 6 291 456 bytes.
  3. KiB = 6 291 456 ÷ 1024 = 6144 KiB.
  4. MiB = 6144 ÷ 1024 = 6 MiB.

Answer: The file size is 6 MiB.

Ask about this

Type what you are stuck on. The helper finds the explanation, worked examples and the notes to read, free and instant.

Keep going

← Text, sound and imagesTypes and methods of data transmission →Take a Computer Science test