A brief note on Storage Units and Compression . Read it before a test. Try each question at the end before you open its answer.
The units Bit: a single 0 or 1. Nibble: 4 bits. Byte: 8 bits. KiB, MiB, GiB, TiB, PiB, EiB: each is 1024 of the one before. Down the ladder, multiply by 1024. Up the ladder, divide. Always use 1024, never 1000. File sizes Image bits = = = width × \times × height × \times × colour depth. Sound bits = = = sample rate × \times × resolution × \times × seconds. Divide by 8 for bytes, then by 1024 for each step up. Answer in the unit asked for. To count files that fit, use one unit for both and round down. Compression Why: less storage space, less bandwidth, shorter transmission time. Lossy: removes data for good. Lower the resolution or colour depth of an image, or the sample rate or resolution of a sound. Lossless: no data is lost. Example: run-length encoding. Run-length encoding stores each run as a count and a value. It helps when there are long runs, and makes data with no runs bigger. A worked example An image is 128 by 96 pixels with a colour depth of 16 bits. Find its size in KiB.
Bits. 128 × 96 × 16 = 196608 128 \times 96 \times 16 = 196608 128 × 96 × 16 = 196608 bits. Bytes. 196608 ÷ 8 = 24576 196608 \div 8 = 24576 196608 ÷ 8 = 24576 bytes. KiB. 24576 ÷ 1024 = 24 24576 \div 1024 = 24 24576 ÷ 1024 = 24 KiB. Practice with new numbers
A program to try The program gives a size in every unit from bytes up to GiB, and run-length encodes a short row of pixels.
Read it first. Then run it. In which unit is the number closest to 1?
1. Change the row so that every pixel is W. How many pairs are left?
Mistakes to avoid Using 1000 instead of 1024. Forgetting to divide by 8 to get bytes. Calling RLE lossy. It gives back the exact data. Thinking lossy data can be restored. It cannot. Check yourself How many KiB are in 9 MiB? Stuck? Show a hint Show the answerHow many bits are in 3 bytes? Stuck? Show a hint Show the answerEncode the row of pixels RRRRGGB with run-length encoding. Stuck? Show a hint Show the answerAn image has its colour depth reduced to save space. Is this lossy or lossless? Stuck? Show a hint Show the answerGive one benefit of compressing a file before sending it. Stuck? Show a hint Show the answerSources Cambridge International, IGCSE Computer Science 0478 syllabus for 2026 to 2028, section 1.3 (data storage and compression).