Pack Camo

Number Base Converter

Binary, octal, decimal and hex, plus any base from 2 to 36, with big numbers.

Everything runs locally with zero file uploads.

Conversions

16 bits · 13 bits set · 5 decimal digits

  • Binary (base 2)
    1011 1110 1110 1111
  • Octal (base 8)
    137 357
  • Decimal (base 10)
    48 879
  • Hexadecimal (base 16)
    BEEF
  • 1 1PR

Two's complement

The bit pattern at each width, read as a signed and as an unsigned integer. Click a hex value to copy it.

WidthHex patternSignedUnsigned
8-bitDoes not fit in 8 bits.
16-bit-1665748879
32-bit4887948879
64-bit4887948879
128-bit4887948879

Bits

Click a bit to flip it.

158
70

Bit 15 is the sign bit when the value is read as signed.

Binary, octal, decimal and hex — and every base up to 36

Type a number in binary, octal, decimal, hexadecimal or any base from 2 to 36 and see it in all the others at once. Numbers can be as large as you like — the converter uses arbitrary-precision integers, so a 64-bit or 128-bit value keeps every digit — and negative numbers are shown in two's complement at 8, 16, 32, 64 and 128 bits, with a bit view you can click to flip individual bits. Prefixes like <code>0x</code> and separators like <code>1_000_000</code> are understood. Everything runs in your browser.

How to convert between number bases

  1. 1Choose the base you are typing in: Bin, Oct, Dec, Hex, or Custom for any base from 2 to 36.
  2. 2Type or paste the number. A minus sign, 0x, 0b and 0o prefixes, and spaces, underscores or commas between digits are all accepted.
  3. 3Read the result in every base at once, with digits grouped for readability. Pick any other base in the last row, or turn on All bases 2–36.
  4. 4Check the two's complement table for the signed and unsigned reading at each width, click bits in the bit view to flip them, and copy whichever form you need.

How positional number systems work

In any base, each digit is worth the base raised to the power of its position, counting from zero on the right. In decimal, 255 is 2×10² + 5×10¹ + 5×10⁰. In binary the same number is 11111111: eight ones, worth 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1. In hexadecimal it is FF: 15×16 + 15.

Bases above 10 need more than ten digit symbols, so letters continue the count: A is 10, B is 11 and so on up to Z for 35 — which is why 36 is the largest base that uses the ordinary digits and letters. Letters are read without regard to case.

Why programmers use binary, octal and hex

Binary (base 2)
How the machine stores everything. Useful for bit flags, masks and network subnets, but long: a 32-bit value has 32 digits.
Hexadecimal (base 16)
Each hex digit is exactly four bits, so a byte is two hex digits and a 32-bit value is eight. Used for memory addresses, colors (#FF8800), hashes, UUIDs and byte dumps.
Octal (base 8)
Each octal digit is three bits. Survives mainly in Unix file permissions, where 755 is three groups of rwx bits — see the <a href="/chmod-calculator">chmod calculator</a>.
Base 36 and base 62
Compact, case-insensitive identifiers such as short URLs and IDs use base 36 (0–9 and a–z). Base 62 adds capitals and is outside what this tool covers.

Two's complement and negative numbers

Computers store signed integers in two's complement: at a fixed width of n bits, a negative number −x is stored as 2ⁿ − x. At 8 bits, −1 is 11111111 (0xFF), −128 is 10000000 (0x80), and the top bit doubles as the sign. An 8-bit signed integer holds −128 to 127; the same 8 bits read as unsigned hold 0 to 255.

The two's complement table shows both readings for each common width. Type 0xFFFFFFFF and you see it is 4,294,967,295 as an unsigned 32-bit integer and −1 as a signed one; type -42 and you get its bit pattern at every width. When a value is too large for a width, the row says so rather than silently wrapping it.

Big numbers and precision

JavaScript's ordinary numbers lose precision above 2⁵³ (9,007,199,254,740,992), which is why many online converters get 64-bit IDs and hashes wrong. This converter uses BigInt throughout, so it is exact for numbers of any size — a 128-bit value, a SHA-256 hash read as an integer, or a 20,000-digit number.

Only whole numbers are converted. Fractions in other bases rarely terminate (0.1 in decimal is an endless repeating fraction in binary), so for floating-point bit patterns and for timestamps see the Unix timestamp converter.

Frequently asked questions

How do I convert binary to decimal?
Choose Bin, type the binary number, and read the decimal row. By hand, add the powers of two for every 1: 1011 is 8 + 0 + 2 + 1 = 11.
How do I convert decimal to hexadecimal?
Choose Dec, type the number, and read the hexadecimal row. By hand, divide by 16 repeatedly and write the remainders from last to first: 255 ÷ 16 = 15 remainder 15, so 255 is FF.
What does the 0x prefix mean?
0x marks a hexadecimal number in C, JavaScript, Python and most other languages, just as 0b marks binary and 0o octal. The converter accepts these prefixes in its input and can add them to its output.
How are negative numbers converted?
In each base the result keeps a minus sign, like -2A in hex. The two's complement table and the bit view show how the same number is stored in a signed 8-, 16-, 32-, 64- or 128-bit integer.
Why does 0xFF show as both 255 and -1?
The same eight bits mean 255 when read as an unsigned byte and -1 when read as a signed byte in two's complement. Which is correct depends on the type that stores it.
Is there a limit on the size of the number?
No practical one: numbers up to 20,000 digits are converted exactly, because the converter uses arbitrary-precision integers instead of floating point.
Can I convert fractions or decimals?
No, only whole numbers. Most fractions have no exact representation in other bases, so the converter asks for an integer instead of giving a rounded answer.
Is my input sent anywhere?
No. All conversion happens in your browser.