dev

Binary, Hex, Octal, Decimal: How Number Base Conversion Actually Works (Free Converter)

Convert between binary, hex, octal, and decimal instantly — and understand why a color code, a file permission, and a memory address all use a different base than the number you'd write on paper.

👤FileConvy Team📅 September 8, 2026⏱️ 6 min read
#number base converter#binary to decimal converter#hex to decimal online#decimal to binary converter#number system converter free

#FF5733 is a color. 0755 is a file permission. 0x1A2B is a memory address. All three are just numbers — the digits look unfamiliar because they're not written in base 10. Converting between number bases isn't really a math problem, it's a translation problem: the same quantity, written with a different set of symbols.

What "Base" Actually Means

Every number system is built on the same idea: pick a set of digits, and each position in a number is worth a power of the base.

  • Decimal (base 10) — the one everyone learns first. Digits 0-9. The number 247 means 2×100 + 4×10 + 7×1.
  • Binary (base 2) — digits 0 and 1 only. What a computer actually stores — every value in memory, on disk, or over a network is binary underneath.
  • Octal (base 8) — digits 0-7. Mostly seen today in Unix file permissions (chmod 755).
  • Hexadecimal (base 16) — digits 0-9 then A-F (A=10 … F=15). The universal shorthand for binary, because one hex digit maps to exactly 4 binary digits — no rounding, no ambiguity.

The same value, 247 in decimal, is 11110111 in binary, 367 in octal, and F7 in hex. None of these is more "correct" — they're four labels for the same point on a number line.

Why Hex Exists at All

Nobody wants to read or write raw binary by hand — 11111111 00000000 10101010 is unreadable at a glance. But binary can't just be written in decimal either, because decimal doesn't divide evenly into binary's powers of 2. Hex does: 4 binary digits (a "nibble") always convert to exactly one hex digit, so 1111 is always F, 0000 is always 0, no exceptions. That's why hex shows up everywhere binary needs a human-readable shorthand:

  • Color codes — #FF5733 is three bytes (red, green, blue), each written as 2 hex digits instead of 8 binary digits.
  • Memory addresses and pointers — 0x7FFE1A2B is far easier to read and compare than the 32-bit binary string it represents.
  • MAC addresses — 3C:22:FB:A1:9E:0C, six bytes in hex, colon-separated.
  • Debugging binary data — a hex editor shows file bytes as hex pairs because raw binary would be an unreadable wall of 1s and 0s.

Why Octal Still Shows Up in Unix Permissions

chmod 755 looks arbitrary until you know it's octal, and each digit is 3 bits — read, write, execute:

Octal digitBinaryMeaning
7111read + write + execute
5101read + execute (no write)
4100read only

755 decodes to rwxr-xr-x — owner gets all three, group and everyone else get read+execute. Octal was chosen because 3 bits packs cleanly with the 3 permission bits, the same reason hex pairs cleanly with 4-bit nibbles.

Converting Between Bases by Hand (the Short Version)

Decimal to binary — repeatedly divide by 2, read the remainders bottom-to-top:

13 ÷ 2 = 6 remainder 1
 6 ÷ 2 = 3 remainder 0
 3 ÷ 2 = 1 remainder 1
 1 ÷ 2 = 0 remainder 1

Reading remainders bottom to top: 1101 — so 13 in decimal is 1101 in binary.

Binary to decimal — multiply each digit by its power of 2 and add:

1101 = 1×8 + 1×4 + 0×2 + 1×1 = 8 + 4 + 0 + 1 = 13.

Binary to hex — group into 4-bit chunks from the right, convert each chunk:

11110111 → 1111 0111 → F 7 → F7.

Hex to binary — reverse it: each hex digit becomes exactly 4 binary digits (pad with leading zeros): F7 → 1111 0111 → 11110111.

This is manageable for small numbers but gets error-prone fast for anything beyond 2-3 digits — which is the actual reason a converter exists: not because the math is hard, but because doing it by hand for a 32-bit value invites off-by-one mistakes.

Common Mistakes

  • Forgetting the 0x or 0/0o prefix and misreading the base. 0x1A (hex, =26) and 1A on its own are easy to confuse in code and configs — always check for a prefix before assuming decimal.
  • Padding binary/hex incorrectly. F alone is not the same as 0F in a context expecting a full byte — dropping the leading zero changes byte alignment when grouping into nibbles.
  • Reading octal 0755 as decimal 755. A leading 0 in many programming languages means "this is octal" — 0755 is 493 in decimal, not seven hundred fifty-five. This exact gotcha has caused real bugs in code that parses user input with parseInt() without specifying a radix.
  • Sign confusion in binary. A binary string alone doesn't say whether it's unsigned or two's-complement signed — 11111111 is 255 unsigned but −1 as a signed 8-bit two's-complement number. The bits are identical; the interpretation isn't.

Quick FAQ

What's the fastest way to convert hex to decimal without doing the math myself? Paste it into the Number Base Converter — it converts between binary, octal, decimal, and hex instantly and shows all four at once, so you can sanity-check by eye.

Why does a color code use hex instead of decimal? Because each color channel (red, green, blue) is one byte (8 bits), and 8 bits splits evenly into two 4-bit hex digits with no rounding — decimal doesn't divide evenly into powers of 2, so it can't represent a byte as cleanly.

Is binary the same as "machine code"? Not quite — binary is how all data is stored (numbers, text, images, instructions alike). Machine code specifically refers to binary that a CPU interprets as instructions to execute, as opposed to binary representing, say, a number or a pixel.

Why does 0755 in a file permission mean something different from 755? The leading zero signals octal (base 8), not decimal. chmod 755 and chmod 0755 are actually the same value — the leading zero is just an explicit octal marker most tools accept either way, but relying on it being decimal instead is a common misread.

Related Free Tools

SHARE THIS ARTICLE

TwitterLinkedIn
← Back to Blog
🔢

Try Number Base Converter — Free

Convert numbers between Binary, Octal, Decimal and Hexadecimal. No signup required.

Open Number Base Converter →