What a number base actually is
A base is a counting convention, not a property of a number. The quantity you know as two hundred and fifty-five is written 255 in decimal, FF in hexadecimal and 11111111 in binary. All three notations denote the same thing. Nothing about the value changes — only the symbols used to record it.
Every positional system works the same way: each digit position carries a weight that is a power of the base, and the value is the sum of digit × weight.
Hex FF = 15×16¹ + 15×16⁰ = 240 + 15 = 255
Binary 11111111 = 128+64+32+16+8+4+2+1 = 255
Base 36 is the practical upper limit for a converter like this, because it exhausts the ten digits plus twenty-six letters. Beyond that you would need to invent new symbols or use a different scheme entirely, which is what Base64 does.
Why hexadecimal won
Hex is not arbitrary. It survives because 16 is 2⁴, which means one hex digit maps onto exactly four bits with no remainder and no ambiguity. That single property makes hex a compact, lossless shorthand for binary that a human can actually read.
| Hex | Binary | Decimal | Hex | Binary | Decimal |
|---|---|---|---|---|---|
| 0 | 0000 | 0 | 8 | 1000 | 8 |
| 1 | 0001 | 1 | 9 | 1001 | 9 |
| 2 | 0010 | 2 | A | 1010 | 10 |
| 3 | 0011 | 3 | B | 1011 | 11 |
| 4 | 0100 | 4 | C | 1100 | 12 |
| 5 | 0101 | 5 | D | 1101 | 13 |
| 6 | 0110 | 6 | E | 1110 | 14 |
| 7 | 0111 | 7 | F | 1111 | 15 |
Because a byte is eight bits, a byte is always exactly two hex digits — 00 to FF. This is why memory addresses, colour codes, hashes, MAC addresses and byte dumps are all written in hex. A colour like #CC2936 is three bytes: red CC (204), green 29 (41), blue 36 (54).
Octal, base 8, has the same property against three bits and survives mainly in Unix file permissions. chmod 755 is three octal digits, each encoding three permission bits: 7 = 111 = read, write, execute; 5 = 101 = read and execute.
A worked example
Converting decimal 2026 to hexadecimal by repeated division:
- 2026 ÷ 16 = 126 remainder 10 → digit A
- 126 ÷ 16 = 7 remainder 14 → digit E
- 7 ÷ 16 = 0 remainder 7 → digit 7
- Read the remainders bottom to top: 7EA
Check by expanding: 7×256 + 14×16 + 10 = 1792 + 224 + 10 = 2026. ✓
Going the other way is a straight positional expansion. Converting back to binary is easier still — expand each hex digit into its four bits: 7 = 0111, E = 1110, A = 1010, giving 0111 1110 1010.
Prefixes and how they are read
| Prefix | Base | Example | Languages |
|---|---|---|---|
| 0x | 16 | 0xFF | C, C++, Java, JS, Python, Go, Rust |
| 0b | 2 | 0b11111111 | Python, JS (ES6), Java 7+, Rust |
| 0o | 8 | 0o377 | Python 3, JS (ES6) |
| 0 (leading) | 8 | 0377 | C, older JS — a classic bug source |
| # | 16 | #CC2936 | CSS, HTML colours |
The bare leading zero deserves a warning. In C and older JavaScript, 010 is octal 8, not decimal 10. This has caused real bugs in date handling, where 09 is not even valid octal and throws. Modern languages either require 0o or treat leading zeros as decimal.
Bit width and what fits where
The converter reports how many bits a value needs and which fixed-width integer type will hold it. This matters when data crosses a boundary — a database column, a network protocol, an embedded register.
| Type | Bits | Unsigned max | Signed range |
|---|---|---|---|
| uint8 / byte | 8 | 255 | −128 to 127 |
| uint16 / short | 16 | 65,535 | −32,768 to 32,767 |
| uint32 / int | 32 | 4,294,967,295 | −2,147,483,648 to 2,147,483,647 |
| uint64 / long | 64 | 18,446,744,073,709,551,615 | ±9.22 × 1018 |
Frequently asked questions
Why does my hex value have a leading zero?
What is the largest number this handles?
Why is base 36 the maximum?
How do I convert a fraction or a decimal point?
Why is 0.1 + 0.2 not 0.3?
What are octal file permissions?
Where bases show up in practice
Base conversion is rarely an end in itself. It appears whenever a value is really a packed collection of bits.
| Context | Base | Why |
|---|---|---|
| CSS and HTML colours | 16 | Three bytes, two hex digits each: #CC2936 |
| Unix file permissions | 8 | Three bits per digit maps onto read/write/execute |
| Memory addresses, hex dumps | 16 | One digit per nibble, so byte boundaries stay visible |
| MAC addresses | 16 | Six bytes, written as twelve hex digits |
| Unicode code points | 16 | U+1F680 is the rocket emoji |
| Subnet masks | 2 | The prefix boundary is only visible in binary |
| Feature flags and bitmasks | 2 / 16 | Each bit is an independent boolean |
| Short IDs and licence keys | 36 / 62 | Maximum density in case-insensitive alphanumerics |
Bitmasks: the most common practical use
A bitmask packs several booleans into one integer, each flag occupying a distinct bit. Reading one requires thinking in binary, which is where a converter earns its place.
WRITE = 2 = 0b0010
DELETE = 4 = 0b0100
ADMIN = 8 = 0b1000
User value 11 = 0b1011 = READ + WRITE + ADMIN (not DELETE)
Testing a flag is value & FLAG; setting one is value | FLAG; clearing one is value & ~FLAG. Paste an unfamiliar permission integer into the converter, read the binary, and the individual flags become obvious immediately — which is far faster than working through the arithmetic by hand.
The same pattern underlies Unix chmod, TCP header flags, CPU status registers and most feature-flag systems. Once you can read an integer as bits, all of them become legible.