Convert numbers between binary, octal, decimal, hex and bases 2 to 36, exact up to 5,000 digits, with the steps
Type a number in a base from 2 to 36 and read it in binary, octal, decimal and hex at once, exact up to 5,000 digits, with its bits at the width you pick.
How to use it
Type or paste a number. 0x, 0b and 0o say its base; digits alone are read as decimal, letters a–f as hex. Or pick the base in From. Pick the base to show first in To, or leave Auto: decimal, or hex when you typed decimal. Read every base at once below it, the bits at 8 to 128 bits, and the steps by hand. Copy takes a row’s digits.
Examples
A hex value, every base at once
0xFF
Decimal 255 Hex 0xff Octal 0o377 Binary 0b1111 1111
A negative number as 8-bit two’s complement
-42
Bits 1101 0110 Hex 0xd6 Unsigned 214 Signed -42
Bits: 8. The same 8 bits read as unsigned are 214 (256 − 42).
A fraction that repeats in binary
0.1
0.0(0011)
To: Binary. The part in brackets repeats without end, which is why 0.1 can’t be stored exactly as a binary float.
How the base is found
| You type | Read as | Why |
|---|---|---|
0xFF, 0XFF | hex | the 0x prefix (C, JavaScript, Python, Go) |
0b1010 | binary | the 0b prefix |
0o755 | octal | the 0o prefix (Python, JavaScript) |
ff, 7fffffff | hex | it has the letters a–f |
255, 1,000,000 | decimal | digits only; commas are dropped |
1111_1111, 1111 1111 | as above | spaces, _ and ' between digits are dropped |
Big numbers stay exact
Bases above 16
Questions
- How do I convert a negative number to binary?
Computers store negative integers as two’s complement: invert every bit of the positive number at a fixed width, then add 1. Pick the width in Bits; -1 is 1111 1111 in 8 bits and FFFFFFFF in 32. The page shows both readings of the same bits, signed and unsigned. - Why does a fraction never end in binary?
A fraction ends in a base only when its denominator divides a power of that base. 0.1 is 1/10, and no power of 2 is a multiple of 5, so in binary it repeats: 0.0(0011). The page shows the repeating part in brackets, or the first 64 digits when the repeat is longer; Places sets how many (1 to 1,024). - Does it keep every digit of a very long number?
Yes, up to 5,000 digits. The headline names the digit count when the number is too long to read in one line; every row below holds the whole number and Copy takes all of it. - Is the number I type uploaded?
No. Everything runs in your browser, so your numbers stay on your device. Nothing you paste is uploaded unless you share it.