Number Base Converter

Convert whole numbers between binary, octal, decimal, hexadecimal and any base from 2 to 36, with two's complement for negative numbers. No size limit up to 5,000 digits.

Exact for numbers of any size, unlike calculators that round after 16 digits.

Input is
Auto (0x, 0b, 0o or decimal)
Try:

Converted

Type a number above to see it in every base.

Two's complement

Smallest

How the number is stored as a signed integer (int8 to int128), and what a binary or hex bit pattern means as a signed number.

This converter shows a whole number in binary, octal, decimal and hexadecimal side by side, and in any other base from 2 to 36. It is exact for numbers of any size, handles negative numbers, and explains how a value is stored in a fixed number of bits, which is what you need when reading a memory dump, a network packet, a colour code or a file permission.

0 to 16 in Each Base

DecimalBinaryOctalHex
0000000
1000111
2001022
3001133
4010044
5010155
6011066
7011177
81000108
91001119
10101012A
11101113B
12110014C
13110115D
14111016E
15111117F
16100002010

One hex digit is exactly 4 bits and one octal digit 3 bits, which is why programmers use hex for bytes (two hex digits each) and octal for Unix file permissions such as 755.

Signed Integer Ranges

TypeSmallestLargest
8-bit (int8, sbyte)−128127
16-bit (int16, short)−32,76832,767
32-bit (int32, int)−2,147,483,6482,147,483,647
64-bit (int64, long)−9,223,372,036,854,775,8089,223,372,036,854,775,807

Unsigned types of the same width hold 0 up to twice the largest signed value plus one: 255 for 8 bits, 4,294,967,295 for 32 bits.

Related Tools

Convert colour codes between HEX and OKLCH with HEX to OKLCH, encode bytes as text with Base64, or turn a Unix timestamp into a date with the timestamp converter.

Frequently Asked Questions

How do I convert binary to decimal?

Type the binary number (or paste it with a 0b prefix) and choose Binary under Input is, or leave it on Auto if it starts with 0b. The decimal value appears straight away, together with octal, hexadecimal and any other base. By hand, each binary digit is worth twice the one to its right: 1011 is 8 + 0 + 2 + 1 = 11.

How do I convert decimal to hexadecimal?

Type the decimal number; the hexadecimal value is shown below it. By hand, divide by 16 repeatedly and write the remainders from last to first, using A to F for 10 to 15: 255 is 15 × 16 + 15, so FF.

Is there a limit on the size of the number?

Numbers of up to 5,000 digits are converted exactly. Many calculators, and JavaScript's normal numbers, round anything above 9,007,199,254,740,991 (2^53 − 1); this converter uses arbitrary-precision integers, so 18446744073709551615 (the largest unsigned 64-bit value) converts to FFFFFFFFFFFFFFFF exactly.

What is two's complement?

It is how computers store negative whole numbers. In 8 bits, 0 to 127 are stored as themselves and −1 to −128 as 255 down to 128, so −1 is 11111111 (0xFF). The highest bit then tells the sign. The converter shows the pattern for 8, 16, 32, 64 or 128 bits, and for a binary or hex input also what that pattern means as a signed number: 0xFA in 8 bits is −6.

Why does a hex number look different in 8 and 16 bits?

As a plain number, 0xFF is always 255. As a signed bit pattern, the width matters: in 8 bits the top bit of 0xFF is set, so it means −1; in 16 bits the pattern is 0x00FF and means 255. Choose the width your program uses (an int8, int16, int32 or int64) under Two's complement.

What do prefixes like 0x and 0b mean?

They mark the base in code: 0x for hexadecimal (0xFF), 0b for binary (0b1010) and 0o for octal (0o17), as used in JavaScript, Python, C# and other languages. With Input is set to Auto, the converter reads these prefixes; a number without one is read as decimal. Spaces and underscores between digit groups, as in 1111_0000, are ignored.