Why computers count in binary — and where hexadecimal fits in
Binary is not arbitrary and hexadecimal is not a separate system. Why both exist, why 255 turns up everywhere, and why your 1 TB drive shows as 931 GB.
We count in tens because we have ten fingers. Computers count in twos because a transistor is either conducting or it is not. There is nothing deeper to it than that — binary is what you get when your only reliable primitive is a switch.
Any base works the same way
A number's value comes from digit weights that are powers of the base. In decimal, 255 means 2×10² + 5×10¹ + 5×10⁰. In binary, 11111111 means 1×2⁷ + 1×2⁶ + … + 1×2⁰ — which adds to exactly 255. Same quantity, different notation.
Reliability is why the trade-off is worth it. Distinguishing ten voltage levels on a wire is fragile; distinguishing "high" from "low" survives noise, heat and manufacturing variation. Computers gave up compact notation in exchange for near-perfect certainty about each digit.
Why 255 turns up everywhere
Eight bits — one byte — hold 2⁸ = 256 distinct patterns. Counting from zero, the largest is 255. That single fact explains a remarkable amount of computing trivia:
- Colour channels run 0–255, so pure red is rgb(255, 0, 0) or #FF0000.
- IPv4 address parts max out at 255, which is why 255.255.255.0 is a familiar subnet mask.
- Older games famously broke at 255 items, because the counter had nowhere left to go.
| Bits | Distinct values | Range (unsigned) | Typically used for |
|---|---|---|---|
| 8 | 256 | 0–255 | One byte, a colour channel |
| 16 | 65,536 | 0–65,535 | Port numbers, older integers |
| 32 | 4,294,967,296 | 0–4.29 billion | IPv4 addresses, standard integers |
| 64 | ≈1.8 × 10¹⁹ | Effectively unlimited | Modern integers, timestamps |
Hexadecimal is just shorthand for binary
Binary is reliable for machines and miserable for humans — 11111111 is easy to miscount. Hexadecimal fixes this because 16 is 2⁴, so one hex digit maps to exactly four bits, with no arithmetic required. 1111 is F, always. So 11111111 becomes FF, and a 32-bit value collapses into eight readable characters.
That is the whole reason colour codes, memory addresses and hashes are written in hex. It is not a different number system in any meaningful sense; it is binary with the digits grouped four at a time so people can read them aloud.
Why your 1 TB drive shows up as 931 GB
This is not a scam, but it is a genuine ambiguity. Drive manufacturers use decimal units: 1 TB means exactly 1,000,000,000,000 bytes. Operating systems have traditionally used binary units, where one GB means 2³⁰ = 1,073,741,824 bytes.
So the OS divides that same 1,000,000,000,000 by 1,073,741,824 and reports 931 GB. The drive holds precisely what the box promised — it is simply being measured with a different ruler. The gap widens at every step up, which is why it is barely noticeable on a USB stick and hard to miss on a multi-terabyte disk.
Bitwise operations: working one bit at a time
Once numbers are bit patterns, you can manipulate them directly. AND keeps a bit only where both inputs have it, OR keeps it where either does, XOR only where they differ. Shifting left doubles a number, shifting right halves it.
These are not academic curiosities. AND with a mask is exactly how a router decides which part of an IP address is the network. Permission systems pack a dozen yes/no flags into one integer and read them back with AND. It is the most efficient way to store and test many small facts at once.
Number Base Converter Convert between binary, octal, decimal and hex Bitwise Calculator See AND, OR, XOR and shifts in binary Data Storage Converter Convert bytes, KB, MB, GB and TB