1What a number base actually is (start from zero)

Count on your fingers: 1, 2, 3… 9, and then you're out of digits, so you start a new column and write 10. That "ten digits, then a new column" system is called base 10 (decimal), and the only reason we use it is that humans have ten fingers. It's a biological accident, not a mathematical law.

A base is simply how many distinct digits you get before rolling over to a new column. Base 2 (binary) gives you two digits — 0 and 1 — so counting goes 0, 1, 10, 11, 100… Base 16 (hexadecimal) gives you sixteen digits — 0–9 plus A–F — so counting goes 0…9, A, B, C, D, E, F, 10 (which means sixteen).

The deep point: the quantity doesn't change, only the writing does. Ten apples are ten apples whether you write "10" (decimal), "1010" (binary), "12" (octal) or "A" (hex). Bases are languages, not numbers. Once that clicks, converting is just translation.

Each column in any base is worth the base raised to a power. In decimal, the columns are worth 1, 10, 100, 1000… In binary, they're worth 1, 2, 4, 8, 16… That's the entire machinery — everything else in this guide is that idea, applied.

2The four bases that matter

Dozens of bases exist mathematically, but in practice you'll meet exactly four:

BaseNameDigitsWhere you meet it
2Binary0, 1Inside every computer — the hardware's native language
8Octal0–7Unix file permissions (like chmod 755)
10Decimal0–9Everyday life — prices, ages, phone numbers
16Hexadecimal0–9, A–FColor codes, memory addresses, MAC addresses

Binary: the machine's mother tongue

Two digits, endless combinations. A single binary digit is a bit; eight bits are a byte. Everything digital — your photos, your messages, this article — is stored as long strings of bits. Binary is verbose for humans (255 is eight digits: 11111111) but perfect for hardware.

Octal: the quiet survivor

Base 8 groups bits in threes — one octal digit per 3 bits. It was popular on early computers with 12-bit and 24-bit words, and it survives today in one famous place: Unix file permissions. When you type chmod 755, those three octal digits each encode three permission bits (read/write/execute) for owner, group, and others.

Hexadecimal: binary's readable costume

Base 16 groups bits in fours — one hex digit per 4 bits (a nibble), two hex digits per byte. That's why hex won over octal: bytes are 8 bits, and 8 divides evenly by 4 but not by 3. FF is instantly readable where 11111111 is a wall of digits.

One byte, three costumes 1 1 1 1 1 1 1 1 8 bits = 1 byte nibble → F nibble → F 11111111₂ = FF₁₆ = 255₁₀
Eight bits make a byte; each 4-bit nibble becomes one hex digit. That's why hex is binary's favorite costume — it maps perfectly onto bytes.
Why hex beat octal: a byte is 8 bits. Eight splits into two neat 4-bit nibbles (hex) but not into 3-bit groups (octal). When bytes became the universal unit, hex became the universal shorthand.

3Why computers love binary (and why humans don't)

Computers use binary because hardware is simplest with two states. A transistor is either on or off; a voltage is either high or low; a magnetic spot points either north or south. Building a reliable component with exactly two states is cheap and robust. Building one with ten distinct, reliably distinguishable states is an engineering nightmare.

So everything — text, images, music, video — gets encoded as patterns of bits. The letter "A" is 01000001. A pixel's redness is a number from 0 to 255. Your voice on a call is thousands of amplitude samples per second, each a binary number. It's all just on/off patterns, interpreted by agreement.

Humans hate binary because it's unreadable at scale. Is 1011011010110100 a big number or a small one? You can't tell at a glance. That's why programmers use hex as the human interface to binary: B6B4 carries the same information in a quarter of the digits, and each hex digit maps to exactly 4 bits, so translation is mechanical.

The powers of two are worth knowing by heart — they show up constantly in computing, from RAM sizes to file limits:

PowerValueYou'll meet it as
2¹⁰1,024~1 thousand — the old "K"
2¹⁶65,536Max 16-bit value + 1
2²⁰1,048,576~1 million — the old "M"
2²⁴16,777,216Number of RGB colors
2³⁰1,073,741,824~1 billion — the old "G"
2³²4,294,967,296Max 32-bit value + 1 (the famous 4 GB limit)

4Converting by hand: the exact methods

Two directions, two methods. Learn them once and you'll never feel lost in a hex dump again.

To decimal: multiply by place values and add

Write the place values (powers of the base) under each digit, multiply, and add. In binary the places are 1, 2, 4, 8…; in hex they're 1, 16, 256…

value = digit × base^position, summed over all positions (positions start at 0 on the right)
Worked example 1 — 1010₂ to decimal: 1×2³ + 0×2² + 1×2¹ + 0×2⁰ = 8 + 0 + 2 + 0 = 10.
Worked example 2 — FF₁₆ to decimal: F = 15, so 15×16¹ + 15×16⁰ = 240 + 15 = 255 — the maximum value of one byte.

From decimal: divide by the base, keep remainders

Divide the number by the target base, write down the remainder, repeat with the quotient — then read the remainders bottom-to-top (last remainder first).

Worked example 3 — 255₁₀ to hex: 255 ÷ 16 = 15 remainder 15 → 15 ÷ 16 = 0 remainder 15. Digits 15, 15 → FF. (Read remainders right-to-left: last remainder is the leftmost digit.)
255₁₀ → FF₁₆: divide and collect remainders 255 ÷ 16 = 15 remainder 15 → F 15 ÷ 16 = 0 remainder 15 → F Remainders: 15, then 15 — read them bottom-to-top (last one first) F F  = 255 In hex, digits above 9 are letters: 10=A, 11=B, 12=C, 13=D, 14=E, 15=F.
Repeated division by 16, remainders read last-to-first. The same method works for any base — divide by 2 for binary, by 8 for octal.
The shortcut between binary and hex: group binary digits in fours from the right, convert each group to one hex digit. 1111 1111 → F F. No division needed — this is the trick programmers actually use.

5Reference: 0–20 in all four bases

The Rosetta Stone of number bases. Notice how binary explodes in length while hex stays compact:

DecimalBinaryOctalHex
0000
1111
21022
31133
410044
510155
611066
711177
81000108
91001119
10101012A
11101113B
12110014C
13110115D
14111016E
15111117F
16100002010
17100012111
18100102212
19100112313
20101002414

Two landmarks to memorize: 15 = F (the biggest single hex digit, four 1-bits) and 255 = FF (the biggest byte). Between them you can sanity-check almost any conversion.

6Hex in the wild: colors, addresses, and 0x

Hexadecimal is the one non-decimal base ordinary people meet regularly — usually without realizing it:

The 0x prefix is how code marks a number as hexadecimal: 0xFF means "hex FF" (255), not the letters F-F. You'll see it in C, Python, JavaScript and Rust — anywhere programmers write raw values and need to be unambiguous about the base. (Some contexts use a trailing h instead, like FFh in assembly.)

Anatomy of a hex color: #FF5733 # FF 57 33 hash red = 255 green = 87 blue = 51 Three hex bytes = one color. Try it in our color converter.
Every hex color is three bytes in disguise. FF₅₇₃₃ → rgb(255, 87, 51): the same orange-red from our color guide.
Try this: open our color converter, type any 6-digit hex code, and watch the RGB values appear. You're reading base-16 fluently already — you just didn't know it.

7Common mistakes to avoid

8Pro tips

The 30-second version: to decimal, multiply digits by place values and add. From decimal, divide by the base and read remainders bottom-to-top. Binary ↔ hex goes through 4-bit nibbles. FF = 255 = the biggest byte.

Convert any base in seconds

Binary, octal, decimal, hexadecimal — convert between all four instantly, with every value shown at once. Free, private, no signup.

🔢 Open the Number Base Converter

100% free · No account · Private by design

9Frequently asked questions

What is hexadecimal used for?

Hexadecimal is a compact way to write binary data: one hex digit represents exactly 4 bits. It's used for color codes (#FF5733), memory addresses, MAC addresses, and anywhere programmers need to read raw bytes comfortably.

Why do computers use binary?

Because hardware is simplest with two states: on/off, high/low voltage. A transistor holding one of two states is reliable and cheap to build. Everything a computer does — text, images, video — is ultimately encoded as patterns of these two states.

How do I convert binary to decimal?

Multiply each bit by its place value (powers of 2, right to left: 1, 2, 4, 8…) and add. 1010₂ = 1×8 + 0×4 + 1×2 + 0×1 = 10. The converter does it instantly, but the method is worth learning once.

What is the difference between octal and hexadecimal?

Both are shorthands for binary: octal groups bits in threes (one octal digit = 3 bits), hexadecimal groups them in fours (one hex digit = 4 bits). Hex won because 4-bit groups (nibbles) align perfectly with 8-bit bytes.

What does the 0x prefix mean?

0x marks a number as hexadecimal in code — 0xFF means hex FF (255 in decimal), not the letters F-F. You'll see it in C, Python, JavaScript and CSS-adjacent contexts wherever programmers write raw values.

Why is 255 the maximum value of one byte?

A byte is 8 bits, and the largest 8-bit pattern (11111111₂) equals 255 in decimal — or FF in hex. That's why 255 shows up everywhere: color channels, network masks, and old game scores all max out at 255.

Keep exploring

Number bases power the digital world — these tools live in it:

Related guides

More step-by-step guides on this topic: