Binary, Octal, Decimal and Hex: A Visual Guide
What a number base is, why computers speak binary, why programmers love hexadecimal, and how to convert by hand.
Updated on June 30, 2026 · 7 min read
What a number base is
You have used base 10 since your first math class without ever thinking about it. "Base 10" simply means there are ten different symbols for digits: 0 through 9. When you pass 9, you don't invent a new symbol — you reuse the same digits and shift one place to the left. That is positional notation: a digit's position is worth as much as the digit itself.
Take the number 2025. It isn't "two, zero, two, five" stacked together. Each place is worth a power of 10:
2025 = 2×10³ + 0×10² + 2×10¹ + 5×10⁰ = 2000 + 0 + 20 + 5.
Swap the 10 for another number and you get another base. In base b, each place is worth a power of b, and the valid digits run from 0 to b−1. Base 2 (binary) uses only 0 and 1. Base 8 (octal) uses 0 through 7. Base 16 (hexadecimal) needs sixteen symbols, so it borrows the letters A through F to stand for 10 through 15.
| Decimal | Binary | Octal | Hexadecimal |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 5 | 101 | 5 | 5 |
| 8 | 1000 | 10 | 8 |
| 10 | 1010 | 12 | A |
| 15 | 1111 | 17 | F |
| 16 | 10000 | 20 | 10 |
Look at the last row: "10" shows up in three different bases standing for three different values. "10" in binary is 2, in octal is 8, in hexadecimal is 16. That's why programmers use prefixes to flag the base: 0b for binary, 0o for octal, and 0x for hexadecimal. Without the prefix, 0x10 and 10 are completely different numbers.
Binary: the computer's native tongue
A computer speaks binary not out of preference but because of physics. Deep down, a chip is an ocean of transistors, and a transistor is more reliable when it only has to tell two states apart: current or no current, high voltage or low. Call one of them 1 and the other 0 and you have the bit, the smallest unit of information. Building a circuit that distinguishes ten voltage levels precisely would be expensive and error-prone — two levels are rock solid.
Eight bits make a byte. Because each bit doubles the number of combinations, a byte runs from 0000 0000 to 1111 1111, that is 2⁸ = 256 different values, from 0 to 255. That's why 255 keeps showing up: the maximum red in a color, the last address in a network range, the ceiling of a one-byte field.
To read a binary number, add up the place values where there is a 1. In 1011, from right to left the weights are 1, 2, 4, 8:
1011 = 1×8 + 0×4 + 1×2 + 1×1 = 8 + 2 + 1 = 11.
Octal enters here as a historical shortcut. Since 8 is 2³, each octal digit maps to exactly three bits. Old systems with 12-, 24- or 36-bit words paired nicely with groups of three, and octal still survives in Unix file permissions: chmod 755 is nothing more than 111 101 101 in binary — read/write/execute for the owner, read/execute for everyone else.
Want to see all four bases at once? The Numeric Bases Converter shows binary, octal, decimal and hexadecimal side by side as you type. To convert between two specific bases (including unusual ones like base 3 or base 36), the Number Base Converter handles it.
Hexadecimal: why programmers love it
If the computer thinks in binary and we think in decimal, hexadecimal is the diplomat in the middle. The reason is a happy coincidence: 16 is 2⁴, so each hex digit represents exactly four bits, a chunk called a nibble. Two nibbles make a byte. The result: any byte fits in two hex digits, from 00 to FF.
This makes converting between binary and hex almost visual. Take the byte 1001 1100. Split it into two groups of four bits and translate each:
- 1001 = 9
- 1100 = 12 = C
So 1001 1100 = 9C in hexadecimal. In decimal that's 156 (9×16 + 12 = 144 + 12 = 156). Try doing the same by reading "one hundred fifty-six" to figure out which bits are on — that's exactly the mental fatigue hex removes. A 32-bit value that would be a blur of zeros and ones becomes something short and readable like 0xDEADBEEF.
The 0x prefix flags the base. You see it in memory addresses, error codes, register values, and anywhere the exact bit pattern matters more than the "human" value of the number.
Hex colors and memory addresses
The hex usage most people know isn't even a programmer thing: web colors. A color like #1E90FF is three bytes in a row — one for red, one for green, one for blue. Break the six digits into pairs:
| Hex pair | Channel | Value (0–255) |
|---|---|---|
| 1E | Red | 30 |
| 90 | Green | 144 |
| FF | Blue | 255 |
So #1E90FF is RGB(30, 144, 255), a vivid blue. #FFFFFF is all three channels maxed out: white. #000000 is everything at zero: black. Once you see that each pair is just one byte from 0 to 255, the whole notation stops being mysterious — there's nothing magic, it's binary written compactly.
Memory addresses follow the same logic. When a program crashes and shows something like 0x7FFE0A3C, that's the address of a byte in memory, written in hex because the bit pattern is what matters for debugging. Hashes, UUIDs and cryptographic keys also tend to appear in hexadecimal for the same reason: they represent blocks of bytes that must be shown precisely, without losing a single bit.
There's also the bridge between text and numbers. Every character has a numeric code — the letter "A" is 65 in decimal, 0x41 in hex, 0100 0001 in binary. Tools like the Text ↔ Hex Converter and the Text ↔ Decimal Converter show exactly those codes for each letter of a phrase, which helps make sense of encodings, URLs and binary data.
Converting by hand (and when it isn't worth it)
Knowing how to convert on paper is useful for understanding what happens underneath, even if you reach for a tool day to day. The classic method to go from decimal to any base is successive division: divide by the base value, keep the remainders, and read them from bottom to top.
Decimal 156 to binary
- 156 ÷ 2 = 78, remainder 0
- 78 ÷ 2 = 39, remainder 0
- 39 ÷ 2 = 19, remainder 1
- 19 ÷ 2 = 9, remainder 1
- 9 ÷ 2 = 4, remainder 1
- 4 ÷ 2 = 2, remainder 0
- 2 ÷ 2 = 1, remainder 0
- 1 ÷ 2 = 0, remainder 1
Reading the remainders from bottom to top: 1001 1100. Check it by adding the weights: 128 + 16 + 8 + 4 = 156. It matches.
For hexadecimal, divide by 16: 156 ÷ 16 = 9 remainder 12 (which is C), and 9 ÷ 16 = 0 remainder 9. Bottom to top: 9C. For octal, divide by 8: 156 ÷ 8 = 19 remainder 4, 19 ÷ 8 = 2 remainder 3, 2 ÷ 8 = 0 remainder 2 → 234. To go the other way, multiply each digit by its place value and add, the way we did with 1011.
When isn't it worth it? Any time the number is large, signed, fractional, or you just need the right answer fast — a single transposed digit in the middle of eight divisions slips by and poisons everything. Do two or three by hand to lock in the logic, then let the Numeric Bases Converter take over. The payoff of understanding the process is being able to trust (and double-check) what the tool hands back.
Frequently asked questions
Why does base 16 exist if base 2 is all the computer needs?
For us, the humans. The computer works only in binary, but a long binary number is tiring and easy to misread. Since each hex digit equals exactly four bits, hex shrinks the representation fourfold without distorting anything — it's a compact way to write the same bits. Octal does the same for groups of three bits.
What does the "0x" before a number mean?
It's just a base flag. 0x means hexadecimal, 0b means binary, and 0o means octal. Without the prefix, the computer (and you) would assume decimal. So 0x10 is 16, while plain 10 is ten.
Why does a hex color have six digits?
Because there are three channels — red, green and blue — and each one takes a byte, which fits in two hex digits (00 to FF, or 0 to 255). Two digits per channel, three channels, six digits. Eight-digit versions add a fourth pair for the alpha channel (transparency).
What's the largest number that fits in a byte?
255. A byte has 8 bits, and 2⁸ = 256 combinations, counted from 0 to 255. In binary that's 1111 1111 and in hexadecimal it's FF. That's why one-byte fields, color intensities and IPv4 octets stop at 255.
Does a letter become a number too?
Yes. Every character has a numeric code defined by a table like ASCII or Unicode. Capital "A" is 65, lowercase "a" is 97, and a space is 32. You can view those codes in decimal or hexadecimal with a text converter, which is the foundation of encoding, URLs and binary files.
Tools mentioned in this guide
Numeric Bases Converter
Convert numbers between binary (base 2), decimal (base 10), hexadecimal (base 16) and octal (base 8). Type in any field for instant conversion in the others.
Number Base Converter
Convert numbers between binary (base 2), octal (base 8), decimal (base 10) and hexadecimal (base 16). Instant bidirectional conversion.
Text ↔ Hex Converter
Convert ASCII text to hexadecimal values and vice versa, character by character. Useful for debugging, encoding and protocol analysis.
Text ↔ Decimal Converter
Convert ASCII text to decimal codes and vice versa. Each character is represented by its decimal value in the ASCII table.
Keep reading
Base64: What It Is, What It's For, and When NOT to Use It
The problem Base64 solves, how 3 bytes become 4 characters, legitimate uses like data URLs, and the myth that Base64 "encrypts".
6 min read
Unix Timestamp, ISO 8601 and Time Zones: Taming Dates in Code
What the Unix epoch is, the seconds-vs-milliseconds confusion, the unambiguous ISO 8601 format, and the daylight-saving-time nightmare.
7 min read
Web Colors: HEX, RGB, HSL and CMYK Explained
How screens form colors with additive RGB, HEX as hexadecimal RGB, the logic of HSL, CMYK for print, and contrast for accessibility.
7 min read