Skip to main content

Binary, Decimal & Hex Converter

Enter an integer in binary, octal, decimal, or hexadecimal and read it in all four. Conversions are done by exact integer arithmetic (BigInt) — the same digits a computer scientist would write by hand, at any length.

That matters more than it sounds: ordinary number handling quietly switches to approximations past 2⁵³, so a long hex string fed to a float-based converter comes back with the last digits wrong. Here, a 128-bit value converts digit-for-digit — try the example below.

Spaces or underscores may group digits. A matching prefix (0x, 0b, 0o) is accepted.

Hexadecimal (base 16)

FF

Decimal (base 10)

255

Binary (base 2)

1111 1111

8 bits in the magnitude.

Octal (base 8)

377

How it is worked out

  1. Read as a decimal integer of 3 digits and converted by exact BigInt arithmetic — values of any length stay exact; nothing is rounded at any size.

Embed this calculator on your website →

The formula

value = d₀×b⁰ + d₁×b¹ + d₂×b² + … (read in base b), then written out by repeated division by each target base

  • bases — binary 2, octal 8, decimal 10, hexadecimal 16 (digits A–F = 10–15).
  • exact at any size — all arithmetic is BigInt integer work; nothing passes through a float, so a 128-bit value converts digit-for-digit. Negatives are sign-magnitude, deliberately not two's complement.

Worked example: 255 in decimal = 15×16 + 15 → hex FF, binary 1111 1111, octal 377.

How it works

The value is read digit by digit in its base (each digit times the running total), then written out in each target base by repeated division. Nothing passes through a decimal float at any point, so there is no rounding to hide.

Negative numbers use sign-magnitude notation: −255 is −FF in hex and −11111111 in binary — the minus sign applies to the whole value. This is plain mathematical notation, deliberately not two’s complement: two’s complement only makes sense for a fixed bit width, and this tool assumes none — it converts numbers, not register contents. Type a prefix if you like (0xFF, 0b1010, 0o377) as long as it matches the base you selected, and group digits with spaces or underscores for readability.

Examples

  • 255 (decimal) → hex FF, binary 1111 1111, octal 377 — 8 bits.
  • 1024 (decimal) → hex 400, binary 10000000000, octal 2000.
  • −255 → −FF, −11111111, −377: the sign rides along in every base.
  • 340282366920938463463374607431768211455 (2¹²⁸ − 1) → hex is exactly 32 F’s, binary exactly 128 ones — a float-based tool cannot even hold this number.

Frequently asked questions

Why are there letters in hexadecimal?

Base 16 needs sixteen digit symbols, and 0–9 only provide ten. A–F stand in for the values ten to fifteen, so FF is 15 × 16 + 15 = 255. Input is case-insensitive: ff, FF, and Ff are the same number.

Why doesn't a negative number show as two's complement?

Two's complement is a storage scheme: the answer depends on whether the value lives in 8, 16, 32, or 64 bits, so −1 could be FF, FFFF, or FFFFFFFF. Without a stated width there is no single right answer, so this tool uses the mathematical convention — one sign, one magnitude — and says so openly.

It rejected my input and named a character — why?

Each base has its own digit set: binary uses only 0 and 1, octal 0–7, decimal 0–9, hex 0–9 and A–F. A 2 in a binary string or a G in a hex string is almost always a paste from the wrong base, so the message names the offending character and the digits that base allows.

How large a number can it handle?

Up to 4,096 digits in the input base, at full exactness — far past the 64-bit and 128-bit values used in computing. The conversion cost grows with length, but correctness never degrades.