Bits, Bytes and Units of Storage
Your phone might say a photo is 3 MB, a film is 4 GB, and your
broadband runs at 50 Mb/s. Those little letters — MB, GB,
Mb — are all built out of one tiny thing: the
bit. This page is
about how we count bits, group them into bytes, and pile bytes up into the kilobytes,
megabytes and gigabytes you meet every day.
Remember from binary: a bit is a single 0 or
1 — one switch, on or off. A bit on its own can't say very much, so
computers work with bits in groups. The most important group has a name of its own: the
byte.
Bit, nibble, byte
Bits are grouped into standard bundles. The two you must know for GCSE are the
nibble and the byte:
- 1 bit = a single 0 or 1.
- 1 nibble = 4 bits (yes, half a byte — the name is a computer-scientist's joke).
- 1 byte = 8 bits. This is the everyday "unit" of storage — roughly enough to hold one letter of text.
So a byte such as 01000001 is eight bits in a row. That particular
pattern is how a computer stores the capital letter A.
The big idea: n bits make 2^n patterns
Here is the single most important fact on this page. Each bit can be one of
2 things (0 or 1).
Add a second bit and every old pattern splits into two — a version ending in
0 and a version ending in 1. So each extra bit
doubles the number of patterns:
\text{patterns} = 2^n \quad\text{for } n \text{ bits}
- 1 bit → 2^1 = 2 patterns: 0,\ 1
- 2 bits → 2^2 = 4: 00,\ 01,\ 10,\ 11
- 3 bits → 2^3 = 8
- 4 bits (a nibble) → 2^4 = 16
- 8 bits (a byte) → 2^8 = 256
That last line is worth memorising: one byte can hold 256
different values — the whole numbers 0 to
255. It's why colour channels, ASCII codes and so many computer things
stop at 255.
Notice how quickly the curve rockets upward — that steep climb is exponential
growth, and it's why adding just a few more bits gives a computer vastly more room.
Try it — how many values fit in n bits?
In TypeScript, 2 ** n means "2 to the power
n". Change n below and press Run to see how
the number of patterns explodes as bits are added:
// How many different values can n bits represent?
const n: number = 8; // try 1, 4, 8, 16 ...
const values: number = 2 ** n;
console.log(n + " bits can represent " + values + " different values");
console.log("(the whole numbers 0 to " + (values - 1) + ")");
Stacking bytes into bigger units
One byte is tiny, so we bundle bytes into larger units. Each step up multiplies by
1000:
- 1000 bytes = 1 kilobyte (KB) — about a short email.
- 1000 KB = 1 megabyte (MB) — a photo or a song.
- 1000 MB = 1 gigabyte (GB) — a film.
- 1000 GB = 1 terabyte (TB) — a large hard drive.
So the ladder goes byte → KB → MB → GB → TB, each rung
1000 times the last. To go up the ladder you divide by
1000; to come down you multiply. This little converter does the
arithmetic — change the number and unit and Run:
// Convert a file size into bytes, then into the other units.
const size: number = 4;
const unit: string = "GB"; // "KB", "MB", "GB" or "TB"
const factor: number = { KB: 1e3, MB: 1e6, GB: 1e9, TB: 1e12 }[unit] ?? 1;
const bytes: number = size * factor;
console.log(size + " " + unit + " = " + bytes.toLocaleString() + " bytes");
console.log("That's " + (bytes / 1e6).toLocaleString() + " MB");
console.log("Or " + (bytes / 1e3).toLocaleString() + " KB");
The prefixes come from the metric system you already use in science: kilo means
a thousand (a kilogram is 1000 grams), mega
means a million, giga a billion (a thousand million), and tera
a trillion. Storage just borrows the same words, so 1 MB really is a
"mega" (million) bytes — the same "mega" as a megawatt or a megapixel.
Watch out — two classic traps
A bit and a byte are not the same, and the difference
matters. The rule is 8 bits =
1 byte. To keep them apart, a lower-case
b means bits and an upper-case B means
bytes.
This trips people up with the internet. Broadband speeds are quoted in bits per
second (Mb/s, megabits) but file sizes are in bytes
(MB, megabytes). Because there are 8 bits in a byte, a
80 Mb/s connection downloads at only about
80 \div 8 = 10 MB per second — which is why a "80
megabit" line feels slower than the big number suggests. Divide the bits-per-second figure by
8 to get the bytes-per-second you actually feel.
For GCSE the simple rule is ×1000 per unit
(KB, MB, GB, TB) — that's what disk manufacturers and exam boards use. But because computers work
in binary, it
is sometimes tidier to jump by 1024 instead
(1024 = 2^{10}). To avoid confusion, the "binary" units get an extra
"i": a kibibyte (KiB) is 1024 bytes, a
mebibyte (MiB) is 1024 KiB, and so on. This is why a
"1 TB" drive can look like it holds only about
931 GB in your operating system: the shop counted in
1000s, the computer displayed 1024s. Unless
told otherwise, stick with \times 1000.
Putting it together
A worked example. Suppose a plain text file has 2000 characters, and each
character is stored in 1 byte.
- Size in bytes: 2000 characters × 1 byte = 2000 bytes.
- Size in KB: 2000 \div 1000 = 2 KB.
- Size in bits: 2000 \times 8 = 16{,}000 bits.
And each of those bytes, being 8 bits, could hold any of
2^8 = 256 different values — plenty for every letter, digit and
punctuation mark on your keyboard.