Every number system is built on the same idea: a base that determines how many unique digits exist, and positional notation where each position is worth a power of that base. We use base 10 by habit. Computers use base 2 internally. Programmers regularly encounter base 8 and base 16. Understanding how they all work unlocks a large part of how computers represent data.
The same number in four bases
The decimal number 255 looks completely different depending on which base you use to express it:
255 is a significant number in computing — it is the maximum value of an 8-bit unsigned integer (one byte), and it is the maximum value of a single RGB color channel.
Binary (base 2)
Binary uses only two digits: 0 and 1. Each position is a power of 2. Binary maps directly to the physical reality of digital electronics — a transistor is either off (0) or on (1).
Every piece of data a computer handles — text, images, programs — is ultimately stored as binary. Understanding binary is how you understand bytes, bits, bitwise operations, and memory sizes.
Octal (base 8)
Octal uses digits 0–7. Each octal digit represents exactly three binary digits, which made it convenient in early computing when word sizes were multiples of 3. Today it is most commonly seen in Unix/Linux file permissions.
The chmod 755 command makes a file executable by everyone but only writable by the owner. Each digit (7, 5, 5) maps directly to three permission bits.
Hexadecimal (base 16)
Hexadecimal uses digits 0–9 plus letters A–F for values 10–15. Each hex digit represents exactly four binary digits (a "nibble"), so one byte is always exactly two hex digits. This makes hex a compact, readable representation of binary data.
Hex appears constantly in programming: CSS colors (#FF6B6B), memory addresses (0x7fff5fbff8a0), byte-level data in debuggers, cryptographic hashes (sha256: a9b8c7...), and UUID values.
Reference table: 0–16 in all four bases
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
| 0 | 0000 | 0 | 0 |
| 1 | 0001 | 1 | 1 |
| 2 | 0010 | 2 | 2 |
| 4 | 0100 | 4 | 4 |
| 8 | 1000 | 10 | 8 |
| 10 | 1010 | 12 | A |
| 15 | 1111 | 17 | F |
| 16 | 10000 | 20 | 10 |
| 255 | 11111111 | 377 | FF |
| 256 | 100000000 | 400 | 100 |
Converting between bases in code
0b for binary, 0o for octal, 0x for hex. 0xFF, 0b11111111, and 255 are all the same value to the compiler.