Binary, Octal, Hex, Decimal: The Only Number Base Guide You Need
Every number you have ever written down is a lie — a convenient shorthand built on an arbitrary agreement that we count in groups of ten. Computers never got that memo. They count in groups of two, and everything else — octal, hexadecimal, the color #FF6B35 on your website, the Unix timestamp 1719100800 — flows from that single foundational decision. Understanding positional number systems is not an academic exercise. It is the difference between reading machine output as noise and reading it as information.
What "Base" Actually Means
A positional number system assigns value to a digit based on where it sits in a string of characters, not just what the character is. The base (also called the radix) tells you how many distinct symbols the system uses before it has to roll over to the next position.
In base-10 (decimal), we have ten symbols: 0 through 9. When we exhaust them, the units column resets to 0 and we add 1 to the tens column. Each column is worth ten times the column to its right. So the number 347 is literally (3 × 10²) + (4 × 10¹) + (7 × 10⁰) = 300 + 40 + 7.
That pattern — multiply each digit by its base raised to its position — works identically in every positional system. Change the base, change the multiplier, keep everything else.
The Four Systems Worth Knowing
Base-2 (Binary)
Two symbols only: 0 and 1. A single binary digit is a bit. Eight bits make a byte. The reason computers use binary is not mystical: transistors have two stable states — conducting or not conducting, charged or uncharged. Representing ten states reliably in silicon is engineering hell. Representing two is trivially simple and arbitrarily fast.
The number 1011 in binary is (1 × 2³) + (0 × 2²) + (1 × 2¹) + (1 × 2⁰) = 8 + 0 + 2 + 1 = 11 in decimal.
Base-8 (Octal)
Symbols 0–7. Octal was once everywhere in Unix file permissions, and you still see it there today. The command chmod 755 is three octal digits: owner gets 7 (read+write+execute), group gets 5 (read+execute), others get 5. Each octal digit maps cleanly to exactly three binary digits, which made manual binary reading manageable before hex editors existed.
Base-10 (Decimal)
The system you use without thinking. Biologically motivated — ten fingers — but computationally awkward. Decimal fractions like 0.1 cannot be represented exactly in binary floating-point, which is why 0.1 + 0.2 in most programming languages does not equal 0.3. That is not a bug; it is physics meeting mathematics.
Base-16 (Hexadecimal)
Symbols 0–9 then A–F, where A=10, B=11, C=12, D=13, E=14, F=15. Hexadecimal is the working language of programmers everywhere because each hex digit represents exactly four binary digits (a nibble). One byte — eight bits — becomes two hex digits. FF in hex is 1111 1111 in binary and 255 in decimal. Memory addresses, color codes, SHA hashes, IPv6 addresses, assembly instructions: all hex.
Converting Between Systems: The Actual Method
Any Base → Decimal
Multiply each digit by the base raised to its positional index (starting from 0 on the right), then sum everything.
Example — Hex to Decimal: Convert 2FA16 to decimal.
2 × 16²= 2 × 256 = 512F × 16¹= 15 × 16 = 240A × 16⁰= 10 × 1 = 10- Total: 512 + 240 + 10 = 762
Decimal → Any Base (Repeated Division)
Divide the number by the target base, record the remainder, then divide the quotient again. Read the remainders bottom-to-top.
Example — Decimal to Binary: Convert 45 to binary.
- 45 ÷ 2 = 22 remainder 1
- 22 ÷ 2 = 11 remainder 0
- 11 ÷ 2 = 5 remainder 1
- 5 ÷ 2 = 2 remainder 1
- 2 ÷ 2 = 1 remainder 0
- 1 ÷ 2 = 0 remainder 1
- Read upward: 101101
Verify: (1×32) + (0×16) + (1×8) + (1×4) + (0×2) + (1×1) = 32 + 8 + 4 + 1 = 45. ✓
Binary ↔ Hex (The Fast Path)
This conversion is so clean it feels like cheating. Group binary digits into chunks of four from the right, then replace each group with its hex digit.
Example: Convert binary 10111100 to hex.
- Split:
1011|1100 - 1011 = 8+2+1 = 11 = B
- 1100 = 8+4 = 12 = C
- Result: BC16
The reverse is identical: expand each hex digit into four binary digits. 3D becomes 0011 1101. No arithmetic required.
Binary ↔ Octal (Groups of Three)
Same principle, but group into threes. Binary 110101 splits as 110 | 101 = 6 | 5 = 65 in octal.
Where This Shows Up in Real Work
Color Codes
The hex color #FF6B35 is three bytes packed together: FF (red = 255), 6B (green = 107), 35 (blue = 53). CSS also accepts rgb(255, 107, 53) — same values, decimal notation. Designers manipulate colors visually, but the underlying representation is always binary, usually displayed as hex because it is compact and human-readable. When you use a color picker in Figma or Photoshop, the hex input is doing exactly the base conversion above.
Shorthand hex like #F63 doubles each digit: #FF6633. This only works when both nibbles in each byte are identical, which is why only a subset of colors have valid shorthand forms.
Unix Timestamps
The Unix timestamp 1719100800 represents seconds elapsed since 00:00:00 UTC on January 1, 1970 (the "Unix epoch"). In hex, that same number is 0x668D7B80 — four bytes, easily fits in a 32-bit integer. This is exactly why the Year 2038 problem exists: signed 32-bit integers max out at 0x7FFFFFFF = 2,147,483,647 seconds after the epoch, which maps to January 19, 2038, 03:14:07 UTC. The number overflows and wraps negative. Systems running 64-bit timestamps extend the runway by roughly 292 billion years.
Converting a timestamp to a human date requires arithmetic that no one does by hand — that is where timestamp converter tools earn their keep. But understanding that the number is just seconds-since-epoch helps you sanity-check outputs immediately. If a converter returns 1970, the timestamp is near zero. If it returns 2001, you are looking at something near 1000000000 (the Unix billennium, celebrated by programmers on September 9, 2001).
IP Addresses and Subnet Masks
IPv4 addresses are four 8-bit octets written in decimal for human convenience. 192.168.1.1 in binary is 11000000.10101000.00000001.00000001. A subnet mask like /24 (255.255.255.0) means the first 24 bits identify the network — a clean hex boundary at FFFFFF00. Subnetting math is impossible to follow if you cannot mentally shift between decimal and binary.
Using a Number Base Converter Correctly
Online converters handle the arithmetic, but they fail you silently if you feed them garbage. A few rules:
- Know your input base before you paste. The string
101is 5 in binary, 65 in decimal, and 257 in octal. Ambiguous without context. - Watch for prefixes. Programmers prefix hex with
0x, binary with0b, octal with0oor a leading zero. Some converters strip these automatically; others choke on them. - Check bit width for two's complement. Negative numbers in binary depend on the word size.
11111111is 255 as an unsigned 8-bit integer and -1 as a signed 8-bit integer. A generic converter cannot know which you mean — specify. - Timestamp converters need a timezone. A converter that silently assumes UTC will give you a time that is hours off if your event was logged in local time. Always confirm the timezone before trusting the output.
The Mental Model That Makes It Click
Think of a number base as a number of fingers on your counting hand. Ten fingers gave us decimal. Two states in a transistor gave us binary. Sixteen is just binary packaged for human readability — four bits per symbol, no arithmetic required to convert, just pattern matching.
Once you internalize that every base is the same positional structure with a different column multiplier, conversions stop feeling like memorized procedures. You are not learning four separate systems. You are seeing one system through four different lenses, each optimized for a different audience: humans (decimal), circuits (binary), permissions (octal), bytes (hex).
The numbers have not changed. Only the notation has.