OnlineTextLab
Esc

Number Base Converter

Type a number in any base and the others follow, exactly, however large it gets.

Type in any box. The others update, exactly, at any size.

base 10, 0-9
base 16, 0-9, A-F
base 2, 0-1
base 8, 0-7

Runs on your device. Your files and text are not uploaded.

About Number Base Converter

Reading a hex value from a memory dump, working out a bit mask, or checking what 0xFFFFFFFF is in decimal: these conversions come up constantly, and most calculators quietly get large values wrong. There are five boxes here, for decimal, hexadecimal, binary, octal and a base you choose. Type in any of them and the rest update.

Beyond the conversions, you also see how many bits and bytes the number needs, which tells you what type it fits in. Negative numbers get their two's complement pattern at the smallest common width, the form you would see in a debugger or a register.

How it works

All arithmetic uses JavaScript's BigInt, so results stay exact at any size. Ordinary number code would round anything above 2^53, and parseInt has a worse habit: it stops quietly at the first bad digit, so 102 read as binary returns 2. Here, every digit is checked, and an invalid one gets an error naming the digit and the digits that base allows.

Input is forgiving about how numbers are usually written. Underscores and spaces are ignored, decimal accepts thousands commas, and a 0x, 0o or 0b prefix is removed when it matches the box you are typing in. A two's complement pattern is worked out for negatives, using the smallest of 8, 16, 32, 64 or 128 bits that can hold the value.

How to use Number Base Converter

  1. Type in Decimal, Hexadecimal, Binary, Octal or Other base. Try an example loads the largest unsigned 64-bit value.
  2. To use a different radix, change the number next to Other base, from 2 to 36.
  3. Read the cards below: Bits needed, Bytes needed, and the two's complement value for a negative number.
  4. Press Copy beside the value you need.

The largest unsigned 64-bit number

Input
18446744073709551615
Output
Hexadecimal: FFFFFFFFFFFFFFFF
Octal: 1777777777777777777777
Binary: 1111111111111111111111111111111111111111111111111111111111111111

Bits needed: 64
Bytes needed: 8

A floating point calculator would round this to 18446744073709552000. For comparison, -129 needs 16 bits in two's complement and comes out as 0xFF7F, because it does not fit in 8.

When it helps

  • Converting a hex address or error code from a debugger to decimal
  • Building or reading a bit mask in binary
  • Checking whether an ID fits in a 32-bit or 64-bit column by counting bits
  • Finding the two's complement pattern of a negative number for low-level work

Tips for a better result

  • Paste values with their separators. 1101_0110 and 1,000,000 both work, so you do not need to clean them up first.
  • A prefix is only removed in the matching box. In the hexadecimal box, 0b1 is read as the digits 0, B and 1, which is a valid hex number and probably not what you meant.
  • Base 36 uses all digits and letters, which makes it a compact way to write a large number in a short ID.

Good to know

  • It handles whole numbers only. Fractions often have no exact form in another base, so a decimal point gets an error.
  • Inputs are limited to 20,000 digits.
  • Two's complement goes up to 128 bits and appears as hex only. Negative values in the main boxes are written with a minus sign.
  • Digits above 9 are shown in uppercase, and bases above 36 are not available.

Questions people ask

Why does -1 show as -1 in binary and not as all ones?

The boxes show the mathematical value with a minus sign. The bit pattern a computer stores depends on its width, so that goes in the two's complement card: 0xFF at 8 bits.

How many bits does my number need?

The Bits needed card shows it. 255 needs 8 and 256 needs 9, so a value only fits an unsigned type that wide or wider, and a signed type needs one bit more.

Why do I get an error about an invalid digit?

That digit is not part of the base, such as a 2 in binary or a G in hexadecimal. Many tools silently stop reading at that point, which can give you a wrong answer that looks fine.

Is there a limit on how big a number can be?

Precision has no limit, since all digits are kept. The input is capped at 20,000 digits to keep the page responsive.

What to use next

Last reviewed . Read our editorial policy.