OmniFeed Search

Number base converter

Type a whole number of any length, and the converter writes it exactly in binary, octal, decimal, hex, and any other base up to 36. In Auto mode, a 0x, 0o, or 0b prefix sets the input base, and a number without one is read as decimal. It runs in your browser; nothing you enter is uploaded.

Binary
Octal
Decimal
Hexadecimal
Other base

How base conversion works

In base b, each digit is multiplied by a power of b, and its position decides which power. Hex 2f is 2 × 16 + 15 = 47. Going the other way, 47 is 32 + 8 + 4 + 2 + 1, so in binary it's 101111. And since 47 is 5 × 8 + 7, it's 57 in octal. The letters a to f stand for 10 to 15 in hex, and higher bases carry on through the alphabet up to z, which is 35 in base 36.

One hex digit is exactly 4 bits and one octal digit exactly 3. That's why hex lines up with bytes: ff is 11111111, and every byte is two hex digits.

What you can type

The converter takes whole numbers only. If you type a digit that doesn't exist in the input base, such as 2 in binary or g in hex, the error names the character and the digits that base allows.

Why large numbers stay exact

JavaScript numbers are 64-bit floating point, and they hold every integer exactly only up to 253 − 1, or 9,007,199,254,740,991, which JavaScript calls Number.MAX_SAFE_INTEGER. Above that, parseInt('9007199254740993') returns 9007199254740992, and a converter built on it changes your number without telling you. This converter uses BigInt, which has no fixed size, so 2100 converts to 1267650600228229401496703205376 in decimal and to a 1 followed by 25 zeros in hex, every digit exact.

In code and on the command line

Questions

Why is 010 read as ten and not eight?

Because Auto mode follows the newer rule, where only 0o means octal. In C, a leading zero means octal, so 010 is 8. Python 3 rejects 010 in code and uses 0o10 instead, and JavaScript rejects it in strict mode.

What is base 36?

It's the largest base you can write with the digits 0 to 9 and the letters a to z. It makes short IDs that read the same in upper or lower case, and JavaScript's toString and parseInt accept bases up to 36 as well.

More in data and formats

Other tools