What is a number base?
A number base, or radix, is how many different digits a counting system uses. We normally count in base 10, with the digits 0 to 9, and each place is worth ten times the one to its right. Computers work in base 2, binary, which uses only 0 and 1, because their circuits have two states.
Hexadecimal, base 16, is a shorthand for binary. Each hex digit stands for exactly four bits, so a byte is two hex digits. Octal, base 8, groups bits in threes and is still used for Unix file permissions.
How to convert between bases
- Type your number. Prefixes like 0x for hex and 0b for binary are accepted.
- Choose the base of the number you typed, or select Other base and enter any base from 2 to 36.
- Read the result in binary, octal, decimal, hexadecimal and base 36.
- Choose an extra output base if you need one.
- Check the two's complement table for the fixed-width forms.
How conversion works
To convert from another base to decimal, multiply each digit by the base raised to the power of its position and add the results. Binary 1011 is 1 x 8 + 0 x 4 + 1 x 2 + 1 x 1 = 11. To convert from decimal to another base, divide repeatedly by the base and read the remainders from the last to the first. For bases above 10, the letters a to z stand for the values 10 to 35.
The calculator uses arbitrary-precision arithmetic, so it does not lose accuracy on numbers that are larger than a normal programming-language integer.
Two's complement
Computers store negative whole numbers using two's complement. In an 8-bit number, the values from 0 to 127 are positive, and the pattern for -1 is 11111111. To find it, write the positive value in binary, flip all the bits and add one. The converter shows the pattern for your number in 8, 16, 32 and 64 bits, or tells you that the value does not fit.
Where you meet other number bases
- Hexadecimal: web colors such as #2563eb, memory addresses, error codes and MAC addresses.
- Binary: bit flags, networking masks and low-level programming.
- Octal: Unix permissions such as 755.
- Base 36 and base 62: short IDs and URL shorteners.
- Base 64: encoding data as text, which is a different system, handled by the Base64 tool.
Example: a hex color to decimal
The web color #2563eb is made of three hexadecimal bytes: 25, 63 and eb. Converting each one to decimal gives 37, 99 and 235, which is the same color written as rgb(37, 99, 235). Type 25, 63 and eb with the hexadecimal input base to see each value. The Color Converter does the full conversion in one step, but this example shows why designers and developers meet hexadecimal so often.
Numbers 0 to 15 in different bases
| Decimal | Binary | Octal / Hex |
|---|---|---|
| 0 | 0000 | 0 / 0 |
| 5 | 0101 | 5 / 5 |
| 8 | 1000 | 10 / 8 |
| 9 | 1001 | 11 / 9 |
| 10 | 1010 | 12 / A |
| 11 | 1011 | 13 / B |
| 12 | 1100 | 14 / C |
| 13 | 1101 | 15 / D |
| 14 | 1110 | 16 / E |
| 15 | 1111 | 17 / F |
Frequently Asked Questions
How do I convert decimal to binary?
Enter the decimal number and read the binary result, or divide by 2 repeatedly and read the remainders backwards.
How do I convert hexadecimal to decimal?
Choose Hexadecimal as the input base, type the value and read the decimal result.
What does 0x mean?
It is a prefix that marks a number as hexadecimal.
What is the largest number I can convert?
There is no fixed limit, because the tool uses arbitrary-precision arithmetic.
What is two's complement?
The way computers represent negative integers in binary.
Why do bases above 10 use letters?
There are only ten numeric digits, so a is 10, b is 11 and so on up to z for 35.
Is anything uploaded?
No. The conversion runs in your browser.