Data Representation

Data Representation

Data storage units, file sizes and compression

Data Storage and Compression Paper 1 15 min read

On this page
  1. In this note
  2. What you should already know
  3. Units of data storage
  4. Calculating file sizes
  5. Why files are compressed
  6. Lossy and lossless compression
  7. Run-length encoding (RLE)
  8. Summary
  9. Ways they test it
  10. What the examiner looks for
  11. Past-paper questions, solved
  12. Common mistakes
  13. Practice
  14. Can I do this?
  15. Quiz

In this note

Syllabus 1.3 Data storage and compression
  • 1.3.1Know the units of data storage, from bit to exbibyte (EiB), and convert between them (always 1024).
  • 1.3.2Calculate the file size of an image file and of a sound file, in the unit asked for.
  • 1.3.3Explain the purpose of and need for compression.
  • 1.3.4Explain lossy and lossless compression, including run-length encoding (RLE), and choose one for a situation.

Before this: Text, sound and images (resolution, colour depth, sample rate and resolution). This is the last page of the chapter.

Part 1Learn the topic

The notes: every idea from the start, with our own examples.

What you should already know

Image and sound settings

Resolution = pixels wide × high; colour depth = bits per pixel; sample rate = samples per second; sample resolution = bits per sample.

Quick check: a sound has 8-bit sample resolution: how many bits does one sample use?

8.

Dividing by 1024

1024 = 2¹⁰. Halving ten times divides by 1024: 2048 ÷ 1024 = 2, 512 ÷ 1024 = 0.5.

Quick check: what is 3072 ÷ 1024?

3.

Units of data storage

UnitEqual toNotes
bit (b)one binary digit, 0 or 1the smallest unit
nibble4 bitsone hex digit
byte (B)8 bits (2 nibbles)one ASCII character
kibibyte (KiB)1024 bytes
mebibyte (MiB)1024 KiB
gibibyte (GiB)1024 MiB
tebibyte (TiB)1024 GiB
pebibyte (PiB)1024 TiB
exbibyte (EiB)1024 PiBthe largest unit on the syllabus
From byte upwards, every step is × 1024 going up and ÷ 1024 going down. Never use 1000 in these questions.
A way to remember the order: Kind Monkeys Get Ten Peanuts Each. KiB, MiB, GiB, TiB, PiB, EiB

General methodConverting between units

  1. Going to a bigger unit: divide (÷ 1024 per step; ÷ 8 from bits to bytes).
  2. Going to a smaller unit: multiply (× 1024 per step; × 8 from bytes to bits).
  3. Count the steps between the two units and do one × or ÷ per step.

Example How many bits are there in 1 KiB?

KiB → bytes → bits: two steps down, so multiply.

  1. 1 × 1024 = 1024 bytes
  2. 1024 × 8 = 8192 bits

Answer 8192 bits

Try it yourself

1
How many nibbles are in 8 bytes?
Show working
  1. 2 nibbles per byte

Answer 16

2
Convert 512 KiB to MiB.
Show answer

Answer 0.5

3
Convert 4 GiB to MiB.
Show answer

Answer 4096

4
How many tebibytes are in 2 PiB?
Show answer

Answer 2048

Calculating file sizes

Image file size (bits)Learn itwidth × height × colour depthresolution in pixels, colour depth in bitsUse it when an image with a resolution and a colour depth
Sound file size (bits)Learn itsample rate × sample resolution × length in secondsrate in Hz (samples per second), resolution in bitsUse it when a recording with a rate, resolution and length
Bits → bytes → KiB → MiBLearn it÷ 8, then ÷ 1024, then ÷ 1024Use it when an answer asked in KiB or MiB

General methodAny file-size question

  1. Multiply the values given to get the size in bits (watch out: a colour depth given in bytes is already bytes).
  2. Divide by 8 to get bytes.
  3. Divide by 1024 for each step up to the unit the question asks for (KiB, then MiB …).
  4. Write the answer in the unit asked, and show each stage: there are marks for the working.

Example An image is 1024 × 768 pixels with a colour depth of 16 bits. Calculate its size in MiB.

Bits first, then ÷ 8, then ÷ 1024 twice.

  1. 1024 × 768 × 16 = 12 582 912 bits
  2. ÷ 8 = 1 572 864 bytes
  3. ÷ 1024 = 1536 KiB
  4. ÷ 1024 = 1.5 MiB

Answer 1.5 MiB

Example A sound is recorded for 60 seconds at a sample rate of 16 384 Hz with a sample resolution of 16 bits. Calculate the size in KiB.

Rate × resolution × seconds gives bits.

  1. 16 384 × 16 × 60 = 15 728 640 bits
  2. ÷ 8 = 1 966 080 bytes
  3. ÷ 1024 = 1920 KiB

Answer 1920 KiB

Try it yourself

1
An image is 640 × 480 pixels with a colour depth of 8 bits. Calculate the file size in KiB.
Show working
  1. 640 × 480 × 8 = 2 457 600 bits
  2. ÷ 8 = 307 200 bytes
  3. ÷ 1024 = 300 KiB

Answer 300

2
An image is 1000 × 1000 pixels with a colour depth of 2 bytes. Calculate the file size in bytes.
Show working
  1. 1000 × 1000 = 1 000 000 pixels
  2. × 2 bytes = 2 000 000 bytes (already bytes: no ÷ 8)

Answer 2 000 000

3
A 5-second sound has a sample rate of 8000 Hz and a sample resolution of 8 bits. Give the size in KiB.
Show working
  1. 8000 × 8 × 5 = 320 000 bits
  2. ÷ 8 = 40 000 bytes
  3. ÷ 1024 = 39.0625 KiB

Answer 39.0625

Why files are compressed

Compression reduces the size of a file. A smaller file:

  • needs less storage space;
  • is quicker to transmit (upload, download, send by email);
  • needs less bandwidth to transmit;
  • uses less of a mobile data allowance;
  • is more likely to fit file size limits, such as email attachment limits.

Lossy and lossless compression

LossyLossless
What it doespermanently removes some datano data is permanently removed: the original file can be restored exactly
File sizemuch smallersmaller, but usually less reduction than lossy
Qualityreduced (often not noticed by people)unchanged
How (examples)reduce the resolution or colour depth of an image; reduce the sample rate or sample resolution of a sound; remove sounds people cannot hear; JPEG, MP3run-length encoding (RLE); indexing repeated words or patterns
Use it forphotos, music and video for sharing or streamingtext and documents, program files, images or sound that will be edited or printed at full quality
Lossy is never suitable for text or program files: removing data would change the words or corrupt the program.

Run-length encoding (RLE)

Run-length encoding is a lossless method. It finds runs of repeated data (characters, or pixels of the same colour) and stores each run once, with the number of times it repeats, instead of storing every item.

Original dataRLEItems stored
AAAAABBBCC (10 characters)5A 3B 2C6 instead of 10
a row of pixels: W W W W W W B B W W W W6W 2B 4W6 instead of 12

For text, a lossless algorithm can also find repeated words or phrases, store each one once in an index, and record the positions where it appears.

RLE only helps when the data has long runs (simple graphics, large areas of one colour). A photo with every pixel different could even get bigger.

Try it yourself

1
Write GGGGGGRRRRB using RLE (number then letter).
Show answer

Answer 6G 4R 1B

2
A file must be emailed and the original must be restored exactly. Which type of compression should be used?
Show answer

Answer Lossless

Summary

  • bit → nibble (4 bits) → byte (8 bits) → KiB → MiB → GiB → TiB → PiB → EiB, × 1024 each step from byte up.
  • Image size (bits) = width × height × colour depth. Sound size (bits) = sample rate × resolution × seconds.
  • Bits ÷ 8 = bytes; ÷ 1024 = KiB; ÷ 1024 = MiB. Answer in the unit asked, show every stage.
  • Compression reduces file size: less storage, quicker transmission, less bandwidth, fits email limits.
  • Lossy permanently removes data (smaller, lower quality). Lossless removes nothing permanently (original restored).
  • RLE (lossless): runs of repeated characters / pixels stored once with the number of repeats.

If you see …

  • "calculate the file size … in KiB"multiply → ÷ 8 → ÷ 1024, show each stage
  • text, documents, programs, editing, printinglossless
  • "describe how lossless compression works"RLE: repeated patterns identified, stored once with the count
Part 2How it is examined

Question types, what the examiner gives marks for, and real past-paper questions solved.

Ways they test it

Type 1 Units

"State how many kibibytes equal a mebibyte" [1]; "Complete each conversion" [4]; "Tick the largest unit" [1]

Spot it unit names.

  1. Know the ladder and 1024.
  2. Show working for conversions with more than one step.

Type 2 File size

"Calculate the file size of the image in kibibytes. Show all your working" [2-3]

Spot it resolution + colour depth, or rate + resolution + length.

  1. Marks: one for each correct stage of working, one for the answer.
  2. Answer in the unit asked.

Type 3 Why compress

"Give two reasons why the file may have been compressed" [2-3]

Spot it "compressed", "reason", "benefit".

  1. Pick from: less storage · quicker to transmit · less bandwidth · email size limit · less data allowance.

Type 4 Choose and justify

"Explain why the musician would choose lossless compression instead of lossy" [3]

Spot it both types named.

  1. Lossless keeps all the data / original quality.
  2. Lossy would permanently remove data and reduce quality.
  3. Link to the scenario: editing, printing, text.

Type 5 Describe a method

"Describe how lossless compression compresses the text file" [3-4]

Spot it "describe how" + lossless.

  1. Name RLE.
  2. Repeating characters / pixels / patterns are identified …
  3. … stored once with the number of repeats (and the colour / position).

What the examiner looks for

"Explain how the image file is compressed using lossless compression" [3]

Marking points (one mark each, up to the marks shown)

  • The size of the file is reduced without permanently removing any data
  • A compression algorithm is used … such as run-length encoding / RLE
  • Repeating pixels are identified / grouped // patterns are identified …
  • … and stored with the number of times they are repeated // indexed

Keywords RLE repeating number of times no data permanently removed

"Explain why lossless was chosen instead of lossy" [3]

Marking points (one mark each, up to the marks shown)

  • Lossless will keep all the data / the image is not changed
  • Lossy would permanently remove data …
  • … and reduce the quality (of the print / recording)
  • Link to the scenario: they want to edit it / print it in detail / it is text

Keywords permanently original quality

Working for a file size

0478/12/M/J/24 Q1Paper 1 · Computer systems3 marks
A 16-bit colour image has a resolution of 512 × 512 pixels. Calculate the file size in KiB. Show all your working.
Credited
  • 512 × 512 × 16 = 4 194 304 bits, ÷ 8 = 524 288 bytes, ÷ 1024 = 512 KiB
  • 512 × 512 = 262 144; × 2 bytes = 524 288 bytes; ÷ 1024 = 512 KiB
Not credited
  • dividing by 1000 (524.288)
  • only the final answer, with a slip in it
Why

Each stage of working earns a mark even if the last number goes wrong. The syllabus always uses 1024.

From: 0478/12/M/J/24 Q1(d) mark scheme

Past-paper questions, solved

0478/12/F/M/23 Q3Paper 1 · Computer systems4 marksFull size
Complete four unit conversions

How to start For each, count the steps on the unit ladder: going up divide, going down multiply.

Show a full-mark answer and the mark scheme

8 bytes = 16 nibbles · 512 KiB = 0.5 MiB · 4 GiB = 4096 MiB · 1 EiB = 1024 PiB

PartAnswer / workingMarksGuidance
3(a)16 · 0.5 · 4096 · 1024B4one mark each
Total: 4 marks
0478/12/M/J/24 Q1Paper 1 · Computer systems3 marksFull size
File size of a 512 × 512, 16-bit image in KiB

How to start Pixels × colour depth gives bits; then ÷ 8 and ÷ 1024.

Show a full-mark answer and the mark scheme

512 × 512 = 262 144 pixels · × 16 = 4 194 304 bits · ÷ 8 = 524 288 bytes · ÷ 1024 = 512 KiB

PartAnswer / workingMarksGuidance
1(d)512 × 512 (= 262 144)M1
1(d)× 16 ÷ 8 // × 2 bytes, then 524 288 / 1024M1max 2 for working
1(d)512 (KiB)A1
Total: 3 marks
0478/12/O/N/24 Q2Paper 1 · Computer systems5 marksFull size
Sound effect file size in KiB; what compression means; one benefit

How to start Rate × resolution × seconds gives bits; then ÷ 8 and ÷ 1024. (d) is recall.

Show a full-mark answer and the mark scheme

(c) 22 016 × 8 × 10 = 1 761 280 bits · ÷ 8 = 220 160 bytes · ÷ 1024 = 215 KiB

(d)(i) Reducing the size of a file. (ii) It takes up less storage space.

PartAnswer / workingMarksGuidance
2(c)Any two stages: 22 016 × 8 then ÷ 8 · × 10 · 220 160 / 1024M2
2(c)215 KiBA1
2(d)(i)reducing the size of a fileB1
2(d)(ii)it will take up / use less storage spaceB1
Total: 5 marks
0478/12/F/M/25 Q2Paper 1 · Computer systems6 marksFull size
An artist chooses lossless compression; name and describe a lossless method

How to start (i) contrast the two types and link to the scenario (people print the image as a poster). (ii) name RLE, then describe it.

Show a full-mark answer and the mark scheme

(c)(i) Lossless keeps all of the image data, so the downloaded image is exactly the original. Lossy would permanently remove data and reduce the quality, and the artist wants users to print a detailed poster.

(c)(ii) Run-length encoding. Runs of repeating pixels of one colour are identified and each run is stored once, as the number of repetitions and the colour code.

PartAnswer / workingMarksGuidance
2(c)(i)Any three: lossless retains all parts of the image // does not delete data · lossy reduces quality · artist wants a detailed image · image may be small anyway / server has space / download time OKB3
2(c)(ii)Run-length encoding (name)B1
2(c)(ii)repeating pixels of one colour / patterns identified · … indexed / put into a table · … as the number of repetitions and the colour codeB2max 2 for describing
Total: 6 marks

Common mistakes

  • ✗ Dividing by 1000✓ Divide by 1024The syllabus says calculations must use 1024.
  • ✗ Forgetting ÷ 8✓ Bits ÷ 8 = bytes, then ÷ 1024Image and sound formulas give BITS.
  • ✗ Answer in the wrong unit✓ Give exactly the unit in the question
  • ✗ "Lossless removes some data"✓ Lossless removes no data permanentlyThat is lossy.
  • ✗ "Compression makes the file faster"✓ "Quicker to transmit / less storage"Be specific.

Practice

Practice: easy, medium, hard

Easy

1
How many bits are in a byte?
Show answer

Answer 8

2
How many MiB are in 3 GiB?
Show answer

Answer 3072

3
Give two benefits of compressing a file.
Show answer

Answer Less storage space; quicker to transmit (or less bandwidth / fits email limits)

Medium

1
A file is 3072 bytes. Give its size in KiB.
Show answer

Answer 3

2
An image is 800 × 600 pixels with 24-bit colour depth. Calculate the size in bytes.
Show working
  1. 800 × 600 × 24 = 11 520 000 bits
  2. ÷ 8 = 1 440 000 bytes

Answer 1 440 000

3
Explain why lossy compression should not be used for a text document.
Show answer

Answer It permanently removes data, so words / characters would be lost and the document corrupted

Hard

1
A 2-minute song is recorded at 32 768 Hz with 16-bit resolution. Calculate the file size in MiB. Show your working.
Show working
  1. 120 s × 32 768 × 16 = 62 914 560 bits
  2. ÷ 8 = 7 864 320 bytes
  3. ÷ 1024 = 7680 KiB
  4. ÷ 1024 = 7.5 MiB

Answer 7.5 MiB

PartAnswer / workingMarksGuidance
32 768 × 16 × 120M1
÷ 8 and ÷ 1024 (twice)M1
7.5 MiBA1
Total: 3 marks
2
A photographer needs to send 40 photos by email but they are too big. Explain which compression they should use and how it reduces the size. [4]
Show answer

Answer Lossy: permanently removes data, e.g. reduces resolution / colour depth / removes detail people won't notice; much smaller files, quicker to send; quality loss acceptable for viewing

Can I do this?

Anything unticked: revise that section first. All ticked: take the quiz.

Quiz

The multiple-choice and guided questions need JavaScript. The concept checks and exam practice below work without it.

Your progress on this note is saved when JavaScript is on.

⬇️ Download this chapter as a PDF: Full notes