Bytes and Beyond
Binary & Number Systems · Foundations track
3 min read
In this module
From Bits to Bytes
A single bit gives you two states. Useful, but not very expressive on its own. To do anything meaningful, computers gang bits together. The most fundamental grouping is the byte: a sequence of exactly 8 bits.
1 byte = 8 bits. A byte can represent 2^8 = 256 different values, from 0 to 255 in unsigned form.
Why 8 Bits?
The choice of 8 bits per byte is partly historical. Early machines experimented with all sorts of groupings; 6-bit, 7-bit, and 12-bit words were all in circulation. The 8-bit byte took over in the 1960s and 70s because it landed on a practical sweet spot: big enough to fit a full character set (uppercase, lowercase, digits, punctuation), small enough to keep hardware lean. IBM's System/360 hammered the 8-bit byte into the industry, and it stuck.
How Many States?
Each bit doubles the number of possible patterns. One bit, 2 patterns. Two bits, 4. Three bits, 8. The formula is 2^n, where n is the number of bits.
For a byte, that's 2^8 = 256 distinct patterns. Enough to encode every letter of the English alphabet (upper and lower), the digits 0 through 9, punctuation, and a set of control characters. Which is exactly what ASCII does.
The visualiser below is set to the value 65, which in ASCII represents the letter A. Toggle the bits to explore other values.
Scaling Up
Bytes are the building block for larger units of storage. These units use powers of 2:
| Unit | Bytes | Power of 2 |
|---|---|---|
| Kilobyte (KB) | 1,024 | 2^10 |
| Megabyte (MB) | 1,048,576 | 2^20 |
| Gigabyte (GB) | 1,073,741,824 | 2^30 |
| Terabyte (TB) | 1,099,511,627,776 | 2^40 |
You'll notice these don't line up neatly with the metric system, where "kilo" means 1,000. Computers work in powers of two, not powers of ten, and 1,024 happens to be the power of two closest to 1,000. So it became the convention.
The gap grows with every step up the table. A binary kilobyte is 2.4% bigger than a decimal one, a gigabyte about 7% bigger and a terabyte nearly 10%. Drive makers use the decimal meaning, so a "1 TB" drive holds 10^12 bytes, and an operating system counting in powers of two reports it as about 931 GB.
Bytes also join up into wider numbers. Two bytes make a 16-bit value, four make 32 bits, eight make 64. The visualiser below has 16 bits set to 0x4142: the left byte is 0x41 (65, the A from earlier) and the right byte is 0x42 (66, a B). Flip bits in one half and only that half of the hex read-out changes, which is why programmers read wide values a byte (two hex digits) at a time.
Which order those bytes go in when they're written to memory is a separate question, called endianness, and you'll meet it in the hexadecimal lesson.
The IEC introduced the terms kibibyte (KiB), mebibyte (MiB), and gibibyte (GiB) to refer to the binary-based sizes unambiguously. In practice, both naming conventions are still widely used.
Get comfortable with bytes and their scale and you'll have the vocabulary you need for memory, storage, and data in every lesson that follows.