Binary vs Hex vs Octal: Number Systems Explained

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:

SystemBaseDigits255 in this baseTypical use
Binary20, 111111111Hardware, logic, bit masks
Octal80–7377Unix file permissions
Decimal100–9255Everyday human math
Hexadecimal160–9, A–FFFMemory, 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:

HexBinaryHexBinary
0000081000
1000191001
20010A1010
30011B1011
40100C1100
50101D1101
60110E1110
70111F1111

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:

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 Converter

Frequently 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.

More converters

Latest from the blog