# Storage Measurement Units (KiB, MiB, GiB)

- **Track:** Cambridge IGCSE™ Computer Science (0478 / 0984) (CAMBRIDGE IGCSE 0478)
- **Module:** Section 1: Data Representation
- **Estimated Duration:** 15 minutes
- **Access:** Open Theory + Free Practice

---

## Theory & Conceptual Background

In digital computing, data capacity and memory size are quantified using a hierarchy of units. Understanding these units and calculating conversions accurately is an essential computer science skill.

Learning Objectives
Order and define the hierarchy of digital storage units from bit to tebibyte.Distinguish between IEC binary prefixes (multiples of $1,024$) and SI decimal prefixes (multiples of $1,000$).Accurately convert values between bits, bytes, and binary storage units.Calculate data transmission and file transfer durations.

The Fundamental Building Blocks
Bit (b): The smallest atomic unit of digital data. A binary digit with a value of either 0 or 1.Nibble: A group of 4 bits (e.g., 1011). Conveniently corresponds to exactly one hexadecimal digit.Byte (B): A group of 8 bits (e.g., 10110010). Standard unit used to measure character storage and memory addressing.

IEC Binary Prefixes vs SI Decimal Prefixes
Historically, the terms "kilobyte" or "megabyte" were loosely used for both 1,000 and 1,024 bytes, creating widespread ambiguity between hard drive manufacturers and operating systems.
To resolve this, international standards organizations (IEC and IEEE) established binary prefixes to represent exact powers of 2 ($2^{10} = 1,024$):

  
    Unit NameAbbreviationBinary Calculation (IEC)Equivalent in BytesEquivalent in Previous Unit
    Byte$\text{B}$$2^0$$1\text{ byte}$$8\text{ bits}$Kibibyte$\text{KiB}$$2^{10}$$1,024\text{ bytes}$$1,024\text{ B}$Mebibyte$\text{MiB}$$2^{20} = 1,024^2$$1,048,576\text{ bytes}$$1,024\text{ KiB}$Gibibyte$\text{GiB}$$2^{30} = 1,024^3$$1,073,741,824\text{ bytes}$$1,024\text{ MiB}$Tebibyte$\text{TiB}$$2^{40} = 1,024^4$$1,099,511,627,776\text{ bytes}$$1,024\text{ GiB}$Pebibyte$\text{PiB}$$2^{50} = 1,024^5$$\approx 1.126 \times 10^{15}\text{ bytes}$$1,024\text{ TiB}$Exbibyte$\text{EiB}$$2^{60} = 1,024^6$$\approx 1.153 \times 10^{18}\text{ bytes}$$1,024\text{ PiB}$
  

Contrast with SI Decimal Units:
SI Prefixes (Base 10):$1\text{ kB (kilobyte)} = 10^3 = 1,000\text{ bytes}$$1\text{ MB (megabyte)} = 10^6 = 1,000,000\text{ bytes}$$1\text{ GB (gigabyte)} = 10^9 = 1,000,000,000\text{ bytes}$$1\text{ TB (terabyte)} = 10^{12} = 1,000,000,000,000\text{ bytes}$

  Note: Why Computers Use Binary Prefixes: Computer memory (RAM) is organized in physical rows and columns driven by binary address lines ($k$ address lines can address exactly $2^k$ distinct bytes). Thus, internal computer architectures inherently double and scale in powers of 2, making $1,024$ the natural multiplier.

Unit Conversion Rules
When converting between binary storage units:
Going from Larger unit $\to$ Smaller unit: Multiply by $1,024$ for each step down.Going from Smaller unit $\to$ Larger unit: Divide by $1,024$ for each step up.Bytes $\leftrightarrow$ Bits: Multiply by 8 to get bits; divide by 8 to get bytes.
+-----+  *1024  +-----+  *1024  +-----+  *1024  +-------+  *8  +------+
| GiB | ----->  | MiB | ----->  | KiB | ----->  | Bytes | ---> | Bits |
|     | <-----  |     | <-----  |     | <-----  |       | <--- |      |
+-----+  /1024  +-----+  /1024  +-----+  /1024  +-------+  /8  +------+
Conversion Examples:
Convert $4\text{ MiB}$ to bytes:
$$4 \times 1,024 = 4,096\text{ KiB}$$
$$4,096 \times 1,024 = 4,194,304\text{ bytes}$$
Convert $16,384\text{ KiB}$ to $\text{MiB}$:
$$\frac{16,384}{1,024} = 16\text{ MiB}$$

Data Transfer Time Calculations
Network speeds and internet bandwidth are typically rated in bits per second (e.g., $100\text{ Mbps} = 100\text{ megabits per second}$), while files are measured in bytes or binary units ($\text{MiB}$).
To calculate how long it takes to transfer or download a file:
$$\text{Time (seconds)} = \frac{\text{File Size (bits)}}{\text{Transmission Speed (bits per second)}}$$
Worked Example:
Problem: How long will it take to download a $25\text{ MiB}$ software patch over a $40\text{ Mbps}$ broadband internet connection?
Convert File Size to bits:
$$\text{File Size in bytes} = 25 \times 1,024 \times 1,024 = 26,214,400\text{ bytes}$$
$$\text{File Size in bits} = 26,214,400 \times 8 = 209,715,200\text{ bits}$$
Express Transmission Speed in bits per second:
$$\text{Speed} = 40\text{ Mbps} = 40 \times 10^6 = 40,000,000\text{ bits/second}$$
Calculate Transfer Duration:
$$\text{Time} = \frac{209,715,200}{40,000,000} \approx 5.24\text{ seconds}$$
Written practice and self-review
A user purchases a hard drive advertised as 2 GB (Gigabytes) and notes that an operating system reports its capacity as approximately 1.86 GiB (Gibibytes).
Explain the mathematical difference between 1 GB and 1 GiB.Calculate the exact number of bytes in 2 GiB.Explain why computer memory (such as RAM) is engineered and measured using binary prefixes rather than decimal units.
Write an explanation before checking the theory. Check that each claim answers the question, uses the correct concept and explains why it applies. Discuss uncertain points with a teacher. The structured exercise below checks specific facts; it does not automatically mark this explanation.

---

## Interactive Exercises & Autotest Specifications

### Exercise 1: Exam-Style Check: IEC Binary Prefixes vs SI Prefixes (Multiple choice, 25 XP)

**Instructions:**
How many bytes are in exactly one gibibyte (1 GiB) compared to one gigabyte (1 GB)?

**Options:**
- **A**: 1 GiB = 1,000 MB = 10^9 bytes, whereas 1 GB = 1,024 MB = 2^30 bytes.
- **B**: Both 1 GiB and 1 GB represent exactly 1,000,000,000 bytes.
- **C**: 1 GiB = 1,024 MiB = 2^30 bytes, whereas 1 GB = 1,000 MB = 10^9 bytes.
- **D**: 1 GiB is an obsolete unit that was replaced by SI metric kilobits.


**Autotest Expectations:**
- **Correct option selected**: `selection_match` -> Expected: `a`

### Exercise 2: Exam-Style Question: Storage Unit Conversions (Fill in blank, 35 XP)

**Instructions:**
Calculate the following digital storage conversions using the binary multiplier (**1,024**):

1. Convert **3 KiB** into bytes: [blank_1]
2. Convert **2 MiB** into KiB: [blank_2]
3. Convert **5,120 KiB** into MiB: [blank_3]


**Starter Code:**
```text
{"word_bank":["3072","2048","5","3000","2000","1024","4","4096"],"template":"1. 3 KiB in bytes: [blank_1]\n2. 2 MiB in KiB: [blank_2]\n3. 5120 KiB in MiB: [blank_3]","prompt":"Exam-Style Question: Storage Unit Conversions","blanks":[{"id":"blank_1"},{"id":"blank_2"},{"id":"blank_3"}]}
```

**Autotest Expectations:**
- **Converted storage values**: `text_exact` -> Expected: `{&quot;blank_1&quot;:&quot;3072&quot;,&quot;blank_2&quot;:&quot;2048&quot;,&quot;blank_3&quot;:&quot;5&quot;}`

### Exercise 3: Application: Check the reasoning (Fill in blank, 30 XP)

**Instructions:**
Work out each answer before submitting. Bytes in 3 KiB: Bits in 256 bytes: KiB in 2 MiB:


**Starter Code:**
```text
{"prompt":"Application: Check the reasoning","template":"1. Bytes in 3 KiB: [blank_1]\n2. Bits in 256 bytes: [blank_2]\n3. KiB in 2 MiB: [blank_3]","blanks":[{"id":"blank_1"},{"id":"blank_2"},{"id":"blank_3"}],"word_bank":["3072","2048","3000","2000","1024","4096","512"]}
```


