Loading...
Storage calculations require both a quantity and a unit. Distinguish the number of bit patterns from the largest represented value, then keep binary and decimal prefixes separate.
What you'll be able to do
A bit has two possible values, 0 and 1. With n independent bit positions there are 2ⁿ patterns. For unsigned integers beginning at zero, the largest value is 2ⁿ-1, so pattern count and maximum value differ by one.
To represent m distinct categories with a fixed-width code, choose the smallest n for which 2ⁿ≥m. Unused patterns may remain when m is not a power of two. A byte is eight bits, and an allocation may need a whole number of bytes even when the logical data use fewer bits.
Decimal prefixes use powers of ten: kB=10³ bytes, MB=10⁶, GB=10⁹ and TB=10¹². Binary prefixes use powers of two: KiB=2¹⁰ bytes, MiB=2²⁰, GiB=2³⁰ and TiB=2⁴⁰. The prefix is part of the unit, not a decorative label.
Historical materials sometimes use KB ambiguously. Follow an explicitly stated convention in a question and report your assumption if necessary. A device capacity described in decimal units and displayed in binary units can have different numerical values without any bytes disappearing.
Multiply the number of items by bits per item to find raw bit storage, then divide by eight for bytes. Include channels, frames or other repeated dimensions when the format requires them. Distinguish raw data from file headers, padding and compression.
For transfer time, divide the number of bits by a compatible bit rate. A rate in megabits per second is not megabytes per second. Real transfers can take longer because of protocol overhead and changing throughput, so describe a raw calculation as an ideal estimate under the given conditions.
| Unit | Bytes |
|---|---|
| 1 kB | 1,000 |
| 1 KiB | 1,024 |
| 1 MB | 1,000,000 |
| 1 MiB | 1,048,576 |
Attempt the task before opening its worked response. Record each change of state, explain the rule used, and check the result against the original requirements. Code examples labelled Python 3 use that language’s conventions; pseudocode states its own assumptions.
Common mistakes to avoid
Key takeaways
Test yourself
Answer a few questions, then review anything you missed.
Start with the quiz above to check the key ideas. You can also choose another topic from the practice library.