Binary, Decimal, Hex & Octal Explained
Why is a colour written as #FF8800? Why do Unix permissions look like 755? Why does everyone say computers “think in ones and zeros”? All three questions have the same answer: number bases. Once the idea clicks, a whole layer of computing stops looking like arbitrary magic.
What a “base” actually means
The base is simply how many distinct digits a system has before it runs out and has to carry to the next column.
Decimal is base 10: digits 0 through 9. Count past 9 and you have no more symbols, so you carry — and write 10, meaning “one group of ten, zero left over.”
That is the entire idea, and every base works identically. Binary has only two digits, so it runs out immediately: 0, 1, then carry → 10. Which in binary means “one group of two, zero left over” — the value we call 2.
There is nothing special about base 10. We use it because we have ten fingers. That is genuinely the whole reason.
Place value: how to read any number
In any base, each column is worth the base raised to a power, counting from zero on the right.
In decimal, 253 means (2×10²) + (5×10¹) + (3×10⁰) = 200 + 50 + 3.
In binary, the columns are 1, 2, 4, 8, 16, 32… — powers of two. So 1011 is:
(1×8) + (0×4) + (1×2) + (1×1) = 11 in decimal.
To convert to a base, repeatedly divide and collect the remainders. Decimal 11 ÷ 2 = 5 r1, 5 ÷ 2 = 2 r1, 2 ÷ 2 = 1 r0, 1 ÷ 2 = 0 r1. Read the remainders bottom to top: 1011. ✓
The four bases you will meet
- Binary (base 2) — digits 0 and 1. How computers physically store everything.
- Octal (base 8) — digits 0–7. Now mostly a historical curiosity, except for Unix file permissions.
- Decimal (base 10) — digits 0–9. The human default.
- Hexadecimal (base 16) — digits 0–9, then A–F for the values 10–15. We ran out of numeric symbols, so we borrowed letters.
Ais ten,Fis fifteen.
Why computers use binary
Not because binary is elegant — because it is physically reliable.
A computer stores data as electrical states. Distinguishing between two states — voltage present or absent, on or off — is easy and robust. A little electrical noise will not flip an “on” into an “off.”
Now imagine building a base-10 computer. Each cell would need to reliably distinguish ten distinct voltage levels, and tell 3 apart from 4 despite noise, heat and manufacturing variation. It is possible, and it is enormously harder and more fragile. Two states is the most robust choice, so that is what won.
Why hex exists (and this is the good part)
Binary is reliable for machines and miserable for humans. The byte 11111111 is easy to miscount, and real data is thousands of bits long.
Hex solves this with a piece of mathematical luck: 16 is 2⁴. Which means exactly four binary digits map onto exactly one hex digit, with no remainder and no ambiguity.
0000→01010→A1111→F
So converting between binary and hex needs no arithmetic at all — just chunk the binary into groups of four and translate each group. 1111 1111 → FF. One byte, always exactly two hex digits.
That is why hex is everywhere: it is a compact, human-readable shorthand for binary, four times shorter and translatable at a glance. Decimal has no such property — 10 is not a power of 2, so decimal and binary do not line up, and converting between them requires real division.
Octal works on the same principle, since 8 = 2³, so one octal digit is exactly three bits. That is precisely why Unix permissions use it: the three permission bits (read, write, execute) fit perfectly into one octal digit. 755 means 111 101 101 — the owner gets all three, and everyone else gets read and execute.
Where you will actually meet each base
- Colours.
#FF8800is three bytes: redFF(255, maximum), green88(136, medium), blue00(0, none). An orange. Once you can read hex, you can read a colour code without a picker. - Memory addresses. Debuggers and crash logs are full of hex, because addresses map onto binary hardware.
- Hashes. An MD5 or SHA-256 output is shown in hex — 256 bits becomes 64 characters rather than an unreadable 256.
- Character codes. Unicode code points are written as
U+0041. - Bit masks and flags. Packing several true/false settings into a single number.
- File permissions. Octal, as above.
A reference table worth internalising
- Decimal 8 = binary
1000= hex8 - Decimal 10 = binary
1010= octal12= hexA - Decimal 15 = binary
1111= hexF - Decimal 16 = binary
1 0000= hex10 - Decimal 255 = binary
1111 1111= octal377= hexFF
That last one is worth memorising outright. 255 = FF = one full byte — the largest value eight bits can hold — and it explains why colour channels, IP address octets and countless other things all top out at 255.
Common points of confusion
- “10” means different things. In binary it is 2, in octal 8, in decimal 10, in hex 16. Context is everything — which is why prefixes exist:
0bfor binary,0ofor octal,0xfor hex. - Hex letters are digits, not text.
Fis a number — fifteen — not a letter. - Leading zeros do not change the value, but they do communicate the width.
0Ftells you this is one byte.
Frequently asked questions
Why does hex use letters? Base 16 needs sixteen digits, and we only have ten numeric symbols. A–F fill the gap.
Is hex the same as binary? They represent the same values. Hex is a shorthand — four bits per hex digit.
Why is 255 everywhere in computing? It is the largest number one byte can hold: eight bits all set to 1.
What does 0x mean? A prefix marking the number as hexadecimal, so 0x10 is 16, not 10.
Convert between bases now
Use our Number Base Converter to switch a value between binary, octal, decimal and hex instantly — all four update as you type. For hex colours specifically, try the Color Converter, and to see how text becomes bits, use Text to Binary.