Computers think in binary, but nobody wants to read a 32-digit string of 0s and 1s. That's why programmers also use hexadecimal and octal — compact ways of writing the exact same values. This guide compares all three systems, shows when each one is used, and teaches the grouping trick that converts between them in your head.
What "base" means
The base (or radix) of a number system is simply how many distinct digits it uses. Decimal is base-10 (digits 0–9); each position is worth ten times the previous one. Change the base and the same positional logic applies — only the multiplier changes:
| System | Base | Digits | 255 in this base | Typical use |
|---|---|---|---|---|
| Binary | 2 | 0, 1 | 11111111 | Hardware, logic, bit masks |
| Octal | 8 | 0–7 | 377 | Unix file permissions |
| Decimal | 10 | 0–9 | 255 | Everyday human math |
| Hexadecimal | 16 | 0–9, A–F | FF | Memory, colors, debugging |
Notice that 255, 377, FF, and 11111111 are the same value — just written in different bases.
Binary: the machine's language
Binary (base-2) mirrors hardware directly: a wire is either on or off, a transistor either conducts or doesn't. Every bit is one binary digit, and eight bits make a byte — the unit everything is measured in. Programmers still read raw binary when working with bit masks, flags, and binary protocols, but for anything longer than a byte it becomes unreadable fast.
Hexadecimal: the programmer's shorthand
Hexadecimal (base-16) exists for one reason: it compresses binary without losing the bit pattern. Because 16 = 2⁴, every hex digit maps to exactly 4 bits:
| Hex | Binary | Hex | Binary |
|---|---|---|---|
| 0 | 0000 | 8 | 1000 |
| 1 | 0001 | 9 | 1001 |
| 2 | 0010 | A | 1010 |
| 3 | 0011 | B | 1011 |
| 4 | 0100 | C | 1100 |
| 5 | 0101 | D | 1101 |
| 6 | 0110 | E | 1110 |
| 7 | 0111 | F | 1111 |
You'll meet hex in memory addresses (0x7fff…), color codes (#FF5733), MAC addresses, and error codes. In code it's usually written with a 0x prefix (0xFF) so nobody mistakes it for decimal. Try converting some values with our hex to decimal converter to build intuition.
Octal: the legacy survivor
Octal (base-8) was popular in the minicomputer era because 8 = 2³ — each octal digit maps to exactly 3 bits, and early machines had word sizes divisible by 3. Today it survives almost entirely in one place: Unix file permissions. When you run chmod 755, each digit encodes three permission bits (read=4, write=2, execute=1): 7 = 4+2+1 (rwx), 5 = 4+1 (r-x). Our octal to decimal converter handles the conversion both ways.
The grouping trick: convert between them mentally
Because 8 and 16 are powers of two, you can convert between binary, octal, and hex without touching decimal — just regroup the bits:
- Binary → hex: group bits in fours from the right, then read each group as one hex digit. 11111111 → 1111 1111 → F F.
- Binary → octal: group bits in threes from the right. 11111111 → 11 111 111 → 3 7 7.
- Hex → binary: expand each digit to 4 bits. A5 → 1010 0101.
Example: convert 101101₂ to hex. Group in fours: 10 1101 → pad the first group to 0010 → 2 D. So 101101₂ = 2D₁₆ = 45₁₀. Check it with our decimal to hex converter or binary to octal converter.
Reading a hex dump
Open any binary file in a hex editor and you'll see a hex dump: offsets in hex on the left, file bytes as hex pairs in the middle, ASCII on the right. A typical line looks like 00000010 48 65 6C 6C 6F 0A |Hello.| — offset 0x10, then bytes 48 65 6C 6C 6F ("Hello") and 0A (newline). Being able to glance at 6C and think "that's 108, lowercase L" is the practical payoff of hex fluency, and it's how reverse engineers and digital-forensics analysts read files every day.
Which should you learn?
Learn all three concepts, but prioritize hexadecimal — it's the one you'll actually read in debuggers, color pickers, and documentation. Keep octal in your back pocket for file permissions. And binary itself never goes away: it's the foundation everything else abbreviates.
Convert between any of these bases instantly:
Open the Hex to Decimal ConverterFrequently asked questions
Why do programmers use hexadecimal instead of binary?
Hexadecimal is compact shorthand for binary: one hex digit represents exactly 4 bits, so a 32-bit value that takes 32 binary digits needs only 8 hex digits. It's far easier to read, write, and spot patterns in.
How many bits are in one hex digit?
One hexadecimal digit represents exactly 4 bits (a nibble). Two hex digits make one byte (8 bits).
What is octal still used for today?
Mostly Unix/Linux file permissions (like chmod 755), where each octal digit maps neatly to 3 permission bits: read, write, execute.
Is hexadecimal the same as hex?
Yes — 'hex' is just the short name for hexadecimal, the base-16 number system using digits 0–9 and letters A–F.