Developer ToolsAny base to 36

Number Base Converter

One value, every representation. Enter it in whichever base you have and read off the rest, including the two’s complement forms that matter when a number has to fit in a fixed number of bits.

Value

Prefixes 0x, 0b and 0o are understood and set the base automatically.

Digits valid for the chosen base
Used only in custom mode
DECIMAL
Binary
Octal
Hexadecimal
Base 36
Custom base
Bits required
Bytes required
Grouped binary

Fixed-width representations

8-bit two's complement
16-bit two's complement
32-bit two's complement
Fits in 8 bits?
Fits in 16 bits?
Fits in 32 bits?

Why 2, 8, 16 and not 7 or 13

Hardware is binary, but binary is unreadable at length. Because 8 and 16 are both powers of two, converting between them and binary needs no arithmetic at all — every hex digit is exactly four bits, every octal digit exactly three. 0xFF is 1111 1111 by inspection. That property is the whole reason those bases became standard, and it is why base 10 is the awkward one in computing.

Two's complement: how negatives are stored

Flip every bit and add one. In 8 bits, −1 becomes 11111111 and −128 becomes 10000000. The reason this representation won is that addition and subtraction need no special case — the same adder circuit handles signed and unsigned values identically, and the carry out of the top bit is simply discarded.

It also explains the asymmetry every programmer meets eventually: an 8-bit signed value ranges from −128 to +127, not −127 to +127, because zero takes up one of the positive slots.

Reading the place-value breakdown

Every base works identically: each digit is multiplied by the base raised to its position, counting from zero on the right. 1011 in binary is 8 + 0 + 2 + 1 = 11. 2F in hex is 2×16 + 15 = 47. The breakdown above spells this out digit by digit, which is the fastest way to convert by hand and to spot a mis-typed digit.

Bits, bytes and why the count matters

The number of bits needed is ⌊log₂(n)⌋ + 1. It determines whether a value fits in a field, how wide a database column has to be, and how many distinct values an identifier can hold. 255 needs 8 bits and fills a byte exactly, which is why it is the boundary that shows up everywhere from colour channels to IPv4 octets.

Frequently Asked Questions

How do I convert hex to decimal by hand?
Multiply each digit by 16 raised to its position from the right, then add. 2F is 2×16 + 15 = 47. The place-value breakdown above shows every step for the value you entered.
What does the 0x prefix mean?
It marks a hexadecimal literal, as 0b marks binary and 0o marks octal. This converter recognises all three and switches the input base for you.
Why does an 8-bit signed number stop at 127?
Two's complement splits 256 possible patterns into 128 negatives and 128 non-negatives, and zero occupies one of the latter. That leaves −128 to +127 rather than a symmetric range.
What is the highest base supported?
Base 36, which uses 0–9 followed by A–Z. Beyond that there are no conventional digit symbols, so higher bases need a custom alphabet rather than a standard notation.
Where these numbers come from

Sources

Official publications only. Links open the original document in a new tab.