EEasy IGCSELabTracker

On a phone the notes, quizzes and tracker work fine. The 3D models and the practice lab are made for a laptop.

Specification points 1.3.1–1.3.4 ·

units of data storage, calculating image and sound file sizes, why files are compressed, and lossy and lossless compression.

1Measuring data storage

The smallest unit is the bit (a single 0 or 1). Each larger unit is a fixed number of the unit before it; from the kibibyte upwards it is always 1024.

bit 0 or 1 nibble = 4 bits byte = 8 bits KiB kibibyte = 1024 bytes MiB mebibyte = 1024 KiB GiB gibibyte = 1024 MiB TiB tebibyte = 1024 GiB PiB pebibyte = 1024 TiB EiB exbibyte = 1024 PiB to a larger unit: ÷ 8 (bits → bytes), then ÷ 1024 at each step to a smaller unit: × 1024 at each step, then × 8 (bytes → bits)
Figure 1. Units of data storage. Multiply to go to a smaller unit; divide to go to a larger one.

Work out a file size

Loading the interactive…

2Calculating file sizes

Formulas

Image file size (bits) = resolution (width × height in pixels) × colour depth

Sound file size (bits) = sample rate (Hz) × sample resolution (bits) × length (seconds)

Both formulas give an answer in bits. Convert to the unit asked for in the question: ÷ 8 for bytes, then ÷ 1024 for each step up. Always use 1024, not 1000. No calculator is allowed, so cancel powers of 2 before multiplying out.

Image. An image is 1024 × 512 pixels with a colour depth of 16 bits. Size in MiB?

  • bits = 1024 × 512 × 16
  • bytes = 1024 × 512 × 16 ÷ 8 = 1024 × 512 × 2 = 1024 × 1024
  • ÷ 1024 = 1024 KiB; ÷ 1024 = 1 MiB

Sound. A 64-second recording uses a sample rate of 32 000 Hz and a sample resolution of 16 bits. Size in KiB?

  • bits = 32 000 × 16 × 64
  • bytes = 32 000 × 16 × 64 ÷ 8 = 32 000 × 128
  • KiB = 32 000 × 128 ÷ 1024 = 32 000 ÷ 8 = 4000 KiB

3Why files are compressed

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

  • less storage space is required;
  • less bandwidth is required to send it across a network;
  • a shorter transmission time — it uploads, downloads or streams faster.

4Lossy and lossless compression

Lossy Lossless
How the size is reduced permanently removes data reduces the size without permanent loss of data
After decompression the original cannot be restored exactly the original is restored exactly
Methods reduce the resolution or colour depth of an image; reduce the sample rate or sample resolution of sound run length encoding (RLE)
Size reduction usually much larger usually smaller
Use when a small loss of quality is acceptable, e.g. photos, music, video every bit must be kept, e.g. text documents, program files

Run length encoding (RLE)

RLE replaces each run of identical, consecutive values with one count and one value.

original 16 values 6 W 3 B 7 W 6 values encoded decompress restored identical to the original — no data lost
Figure 2. RLE on one row of a black-and-white image. The same method works on text: AAAABBBCCCCC → 4A 3B 5C.

Compress a row with run length encoding

Loading the interactive…

RLE only saves space when data has long runs of repeated values. With few repeats (e.g. ABCD → 1A 1B 1C 1D) the "compressed" data can be larger than the original.

Traps
Wrong Right
1 KiB = 1000 bytes 1 KiB = 1024 bytes; every step above the byte is × 1024
The formula gives bytes The formulas give bits — divide by 8 for bytes
Lossless compression means nothing is removed Lossless removes redundant data but the original can be fully restored

Quick check

10 multiple-choice questions. Pick an answer to see whether it is right and why.

  1. How many bytes are in 4 KiB?

  2. Which unit is equal to 1024 GiB?

  3. An image is 256 × 256 pixels with a colour depth of 8 bits. What is its file size?

  4. A 32-second recording has a sample rate of 8000 Hz and a sample resolution of 16 bits. What is its file size?

  5. A file size formula gives 16 384 bits. What is this in KiB?

  6. Which is a benefit of compressing a file before sending it across a network?

  7. Which statement about lossless compression is correct?

  8. Which is a lossy method of compressing an image?

  9. What is the text AAAAAABBBBCC after run length encoding?

  10. Which row of pixels is reduced the most by run length encoding?

Exam-style questions

Write your answer, then show the answer and compare. Nothing here is marked for you: you decide how close you were. What you write is saved in this browser.

Recall

1

How many bits are in a nibble? In a byte?

2

Put in order, smallest first: GiB, KiB, EiB, TiB, MiB, PiB.

3

How many KiB are in 3 MiB?

Calculations

4

An image is 2048 × 1024 pixels with a colour depth of 8 bits. Calculate its size in MiB.

5

An image is 512 × 256 pixels with a colour depth of 24 bits. Calculate its size in KiB.

6

A 128-second sound file has a sample rate of 16 000 Hz and a sample resolution of 8 bits. Calculate its size in KiB.

7

How many 2 MiB images can be stored in 1 GiB?

Compression

8

Encode this row of pixels with RLE: WWWWBBWWWWWWWWBB. How many values are needed before and after?

9

Decode the RLE data 3R 2G 5B.

10

Explain why RLE is not effective on the text ABABABAB.

11

Give two lossy methods of reducing the size of a sound file.

Exam-style

12

Explain why files are compressed before they are sent over the internet.

3 marks
13

A student compresses a text document before emailing it. Identify the type of compression that should be used and explain why.

4 marks
14

Describe the difference between lossy and lossless compression.

4 marks

How well do you know this?

Rate each specification point. It is saved to your tracker as a new revision round.

All points:
  • 1.3.1Understand how data storage is measured
  • 1.3.2Calculate the file size of an image file and a sound file, using information given
  • 1.3.3Understand the purpose of and need for data compression
  • 1.3.4Understand how files are compressed using lossy and lossless compression methods

Settings

Your subjects

Untick the subjects you don't take. They leave the menu, the home page and the tracker. Your ratings are kept, so you can bring a subject back at any time.

Page style

Colours