How to use the number base converter
- Type or paste a whole number. You can use a sign, underscores or spaces between digits, and a prefix of 0b, 0o or 0x.
- Choose the input base. Auto reads a prefix and otherwise assumes decimal. Pick Custom to type in any base from 2 to 36.
- Read binary, octal, decimal, hexadecimal and your custom base at the same time. Each row has its own Copy button.
- To see how a number is stored in a fixed number of bits, choose a two's complement width of 8, 16, 32 or 64.
Worked example
The hexadecimal number 0xDEAD_BEEF is 3735928559 in decimal. The number 11111111 in binary is 255, and 777 in octal is 511.
In 8 bit two's complement, -5 is stored as 11111011, which is FB in hex and 251 if the same bits are read as an unsigned number. The number 2 to the power of 100 is 10000000000000000000000000 in hexadecimal, and it converts exactly because the tool uses big integers.
How conversion works
A number in base b is a sum of digits times powers of b. The tool reads your digits into an exact big integer, so there is no rounding at any length, then writes that integer in each base. Digits above 9 are the letters A to Z, so base 36 uses all of them. The case of letters does not matter on input, and output is uppercase.
A prefix is only read when it matches the input base. In base 16 the text 0b11 is the hexadecimal number 0xB11, because b is a hex digit. Use Auto or the matching base if you want 0b to mean binary.
Errors, limits and what is not supported
If a digit does not exist in the chosen base, the message names the first one and its position, for example the 2 at position 4 in 1012 for base 2. Only whole numbers are supported. A decimal point is reported as an invalid digit, so fractions such as 101.01 are not converted. Input is limited to 4096 digits to keep the page fast.
For chmod style octal permissions see the chmod calculator, and for the Roman system see the Roman numeral converter.
Two's complement
Computers usually store signed whole numbers in two's complement. For a width of n bits, a negative number x is stored as x plus 2 to the power n. The range of an 8 bit value is -128 to 127, and the tool tells you when a number does not fit. If you tick the raw bit pattern option, the input is read as the stored bits instead, so 0xFF with 8 bits means -1. Digits can be grouped in fours (bits) or threes (decimal and octal) to make long values easier to read. Everything runs in your browser.
Assumptions and limits
- Only whole numbers are converted. Fractions and exponents are not supported.
- Numbers have no fixed width unless you choose a two's complement width.
- Input is limited to 4096 digits after prefixes and separators are removed.
- Output letters are uppercase. Grouping and prefixes are for display and are not part of the copied digits, except where you turn them on.
Frequently asked questions
How do I convert binary to decimal by hand?
Multiply each bit by a power of two, counting from 1 at the right, and add them. For example 1101 is 8 plus 4 plus 0 plus 1, which is 13. The tool does the same sum with exact integers.
Why does 0b11 not work as binary in hexadecimal mode?
In base 16 the letter b is a valid digit, so 0b11 is read as the hexadecimal number 0B11. Pick Auto or Binary as the input base to treat 0b as a prefix.
What is the largest number I can enter?
There is no value limit, only a limit of 4096 digits. Numbers are handled as exact big integers, so very large values convert without losing precision.
Why does the tool say my number does not fit in 8 bits?
A signed 8 bit number can only hold -128 to 127. Choose a wider width, or read your value as a raw bit pattern if it is the stored form, such as 0xFF.