Home › Calculators & Converters › Number Base Converter

Number Base Converter

Convert a whole number between bases 2 and 36. Any size is exact, and you can show the 8, 16, 32 or 64-bit two's complement pattern of a negative number.

Digits 0 to 9 and letters a to z, in any case. One optional minus sign at the start.

Value (signed decimal)-
BaseValue
2 (binary)-
8 (octal)-
10 (decimal)-
16 (hexadecimal)-
36-
Everything runs in your browser. The number you type is not sent or stored.

How to use

  1. Type a whole number in the Number box. You may start with one minus sign. The box accepts digits and letters, in any case.
  2. Leave Input base on auto, or choose a base from 2 to 36. With auto, a prefix of 0x, 0o or 0b sets hexadecimal, octal or binary, and a number without a prefix is read as decimal.
  3. To see how a computer stores a negative number, pick a Width of 8, 16, 32 or 64 bits.
  4. Tick Group to split binary and hex digits into fours.
  5. Read the signed decimal value above the table, and the binary, octal, decimal, hexadecimal and base 36 forms in the table.

Worked examples

InputSettingResult
255autobinary 11111111, octal 377, hex ff, base 36 73
0b1101auto13 in decimal, hex d
zzbase 361295 in decimal (35 × 36 + 35), hex 50f
-18 bitspattern 11111111, hex ff, decimal row 255
-10016 bits, grouped1111 1111 1001 1100, hex ff9c
1278 bits01111111, padded to 8 binary digits
2008 bitsrefused: the 8-bit range is -128 to 127

Check -100 at 16 bits by hand. Two to the power of 16 is 65,536, and 65,536 − 100 = 65,436. In hex that is ff9c, since 15 × 4096 + 15 × 256 + 9 × 16 + 12 = 65,436.

How it works

The number is read one digit at a time into a BigInt, which holds whole numbers of any size with no rounding. Each digit is worth its value times the base raised to its place. For hexadecimal ff that is 15 × 16 + 15 = 255. The same exact value is then written out in each base, so even a 29-digit decimal number stays exact in every row. Floating-point numbers lose accuracy above about 9 quadrillion, and this tool does not.

value = sum of (digit x base^position)
negative at width w:  pattern = value + 2^w

Digits. Base 36 uses 0 to 9 then a to z, and output is lower case. A digit that is not below the base is refused with a message that names it. For example, 9 in base 8 is rejected.

Two's complement. Computers store negative whole numbers in a fixed number of bits. At 8 bits the range is -128 to 127. A negative number is shown by adding 2 to the power of the width, so -1 at 8 bits becomes 256 − 1 = 255, which is 11111111. Binary, octal and hex are padded to the full digit count for the width, while decimal and base 36 are not. When a width is chosen, the decimal and base 36 rows show that unsigned pattern, while the signed value stays above the table.

Where each base is used

Common mistakes

Frequently asked questions

How do I convert binary to decimal?

Choose base 2 and type the binary digits. For example 1010 gives 10.

How do I convert hex to decimal?

Type 0x before the digits, or set base 16. FF gives 255.

What is the largest number it can handle?

There is no fixed limit besides what your browser can handle, since BigInt has no fixed size.

Why do negative numbers need a width?

Because the minus sign is not stored in bits. A fixed width and two's complement encode the sign.

Is my number sent anywhere?

No. The conversion runs in your browser.

Related tools