Storage Units, File Sizes and Compression
Units of Data Storage
The smallest unit of data is a bit. Four bits make a nibble. Eight bits make a byte. For larger quantities of data, binary multiples are used. These are based on powers of 1024 (which is \(2^{10}\)) — not powers of 1000.
Binary multiples are based on 1024, not 1000:
- 1 kibibyte (KiB) = 1,024 bytes
- 1 mebibyte (MiB) = 1,024 KiB = 1,048,576 bytes
- 1 gibibyte (GiB) = 1,024 MiB = 1,073,741,824 bytes
- 1 tebibyte (TiB) = 1,024 GiB = 1,099,511,627,776 bytes
Why 1024, Not 1000?
Computer memory and storage are built from circuits that operate in powers of 2. A memory chip with 10 address lines can access \(2^{10} = 1,024\) locations, not 1,000. Binary multiples therefore reflect the actual architecture of digital storage. The prefix “kibi” means \(2^{10}\), “mebi” means \(2^{20}\), “gibi” means \(2^{30}\), and “tebi” means \(2^{40}\). A tebibyte is therefore \(2^{40}\) bytes, or exactly 1,099,511,627,776 bytes.
A common error is to mix up binary multiples with the decimal SI prefixes (kB, MB, GB, TB), which step in 1000s. Practise the 1024-step progression: bytes → KiB → MiB → GiB → TiB, each step multiplying by 1024.
Problem 1: A video file is 3,145,728 bytes. Express this in MiB.
Step 1: Convert bytes to KiB: 3,145,728 ÷ 1,024 = 3,072 KiB.
Step 2: Convert KiB to MiB: 3,072 ÷ 1,024 = 3 MiB.
Problem 2: A cloud storage server has 2 TiB of capacity. How many bytes is that?
Step 1: 1 TiB = 1,024 GiB, so 2 TiB = 2,048 GiB.
Step 2: 1 GiB = 1,024 MiB, so 2,048 GiB = 2,097,152 MiB.
Step 3: 1 MiB = 1,048,576 bytes, so 2 TiB = 2,097,152 × 1,048,576 = 2,199,023,255,552 bytes.
Alternatively: 2 × \(2^{40}\) = \(2^{41}\) bytes.
Every step up the binary multiple ladder multiplies by 1,024: 1,024 bytes = 1 KiB; 1,024 KiB = 1 MiB; 1,024 MiB = 1 GiB; 1,024 GiB = 1 TiB. A tebibyte is \(2^{40}\) bytes — over one trillion bytes.
Why Compression Is Needed
Data compression reduces the size of a file. Smaller files download faster, cost less to transmit and consume less storage. Without compression, a single high-definition video file could occupy several GiB — impractical for streaming at normal broadband speeds. A single uncompressed album of audio at CD quality would fill around 700 MiB; compressed to a common format it may occupy under 100 MiB.
Lossless Compression
Lossless compression reduces file size without throwing any data away. The compressed file is a mathematically equivalent representation of the original — decompressing it recovers the original exactly, with no differences whatsoever.
Lossless compression is essential whenever data integrity matters. Examples include text documents, program code, spreadsheets, database backups and medical scan images. If even one bit of a program file is altered by lossy compression, the program could crash or malfunction. The file format ZIP is a common lossless container. Image format PNG uses lossless compression. Audio format FLAC is lossless.
Lossy Compression
Lossy compression permanently removes some data to achieve a greater size reduction than lossless methods can deliver. The removed data is chosen to be the parts humans are least likely to notice — for images, this might mean merging similar colours; for audio, this might mean removing frequencies that the human ear struggles to detect at certain volumes.
Because the removed data is gone permanently, the original file can never be recovered exactly. However, for media such as photographs, music and video, the human perception system is forgiving enough that a well-compressed lossy file is indistinguishable from the original for most listeners and viewers. JPEG is a lossy image format. MP3 and AAC are lossy audio formats. Most video streaming uses lossy compression.
Lossless:
- No data is permanently removed.
- Original file can be perfectly restored.
- Typically achieves a smaller reduction in file size than lossy methods.
- Essential for text, program code, medical data, databases.
- Example formats: ZIP, PNG, FLAC.
Lossy:
- Data is permanently discarded.
- Original cannot be exactly recovered.
- Can achieve much greater size reductions than lossless.
- Suitable for media (photos, music, video) where human perception fills gaps.
- Example formats: JPEG, MP3, AAC, most streaming video.
Choosing Between Lossless and Lossy
The choice depends entirely on whether data integrity or file size is the priority. For a hospital storing patient scan images, lossless compression is mandatory — a lossy compression artefact could look like a clinical finding and lead to misdiagnosis. For a music streaming service, lossy compression is appropriate — the bandwidth saving is enormous and the quality loss is imperceptible at high bit rates.