Number Base Converter

Convert a number between any bases from 2 to 36, and see exactly how it sits in an 8-, 16-, 32-, or 64-bit register.

Fixed-width views

How the value sits in an N-bit register: the two’s-complement bit pattern, read both ways.

Bits

Runs entirely in your browser. Nothing you paste here is uploaded, logged, or sent to analytics.

Exact past 253

JavaScript numbers are IEEE 754 doubles, so parseInt("9007199254740993") returns 9007199254740992 — off by one, silently. Most online base converters are built on parseInt and toString(radix), which means they give wrong digits for exactly the values developers most often convert: 64-bit IDs, hashes, register dumps, and bitmasks.

This converter uses BigInt throughout. 0xFFFFFFFFFFFFFFFF comes back as 18446744073709551615, not a rounded approximation.

Two's complement, and why −1 is all ones

Signed integers are stored as two's complement: to negate a number, flip every bit and add one. That is why -1 in 8 bits is 11111111, which read as unsigned is 255. Both readings are shown for every width above, because the bug this causes always looks the same — a value that should be small appears as a huge positive number, or vice versa.

The asymmetry follows from the same rule: an 8-bit signed integer spans −128 to 127, not −127 to 127. There is one more negative value than positive, because zero occupies a slot on the positive side.

Literal syntax by language

LanguageBinaryOctalHexSeparators
JavaScript / TypeScript0b10100o170xff1_000_000
Python0b10100o170xff1_000_000
Go0b10100o170xff1_000_000
Rust0b10100o170xff1_000_000
C / C++0b1010 (C++14)0170xff1'000'000 (C++14)
Java0b10100170xff1_000_000
PHP0b10100o17 (8.1+)0xff1_000_000 (7.4+)

Note the C, C++, and Java octal form: a bare leading zero. 012 is ten, not twelve. This is a genuine source of production bugs — it is why the tool above rejects 010.0.0.1 as an IP address, and why most modern languages moved to an explicit 0o prefix.

Paste any of these prefixed literals into any field above and the prefix wins over the field's own base, with a note saying so.

Bit facts

The bits panel reports the population count (how many bits are set — the operation behind POPCNT, Integer.bitCount(), and Python's int.bit_count()), the highest set bit, and whether the value is a power of two. The last is the classic n & (n - 1) == 0 check, useful for validating alignment and capacity arguments.