Quick answer: A number base is how many digits a system uses before it carries to the next place. Decimal is base 10, binary base 2, octal base 8 and hexadecimal base 16. The decimal number 255 is 1111 1111 in binary, 377 in octal and FF in hexadecimal.
Computers store numbers in binary, programmers often read them in hexadecimal, and older Unix permissions use octal. Moving between these by hand is slow and error-prone, so this tool converts a number to all the common bases at once.
Type a number, choose the base it is written in, and the binary, octal, decimal and hexadecimal versions appear straight away. There is also a fifth box for any other base from 2 to 36, and the tool handles numbers far larger than a normal calculator can.
How number bases work
In base 10 each digit is worth ten times the one to its right. In base 2 each digit is worth two times the one to its right, so 1101 means 1×8 + 1×4 + 0×2 + 1×1 = 13. Hexadecimal (base 16) uses the digits 0 to 9 and the letters A to F for 10 to 15, and one hex digit equals exactly four binary digits, which is why programmers like it.
Hex 2F = 2×16¹ + 15×16⁰ = 47
To convert from decimal: divide by the base repeatedly and read the remainders backwards
Bases above 10 use letters for digits, so base 36 uses 0 to 9 and A to Z. Prefixes such as 0x (hex), 0b (binary) and 0o (octal) are accepted, spaces and underscores are ignored, and a leading minus sign is kept. Binary output is grouped in fours for easy reading.
A worked example
Example. The decimal number 255 is 1111 1111 in binary, 377 in octal and FF in hexadecimal. In the other direction, the hex color channel 1A is 26 in decimal.
Numbers in four bases
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 1 | 1 | 1 | 1 |
| 2 | 10 | 2 | 2 |
| 3 | 11 | 3 | 3 |
| 4 | 100 | 4 | 4 |
| 5 | 101 | 5 | 5 |
| 6 | 110 | 6 | 6 |
| 7 | 111 | 7 | 7 |
| 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 |
| 16 | 10000 | 20 | 10 |
| 255 | 11111111 | 377 | FF |
| 256 | 100000000 | 400 | 100 |
One hex digit stands for exactly four binary digits, which is why programmers write bytes and colors in hex.
Common mistakes to avoid
- Reading a hex number as decimal. 10 in hex is 16, so always note the base, for example with the prefix 0x.
- Dropping leading zeros in fixed-width values. Bytes and color codes are usually written with a set number of digits, such as 0A rather than A.
- Entering a digit that is not allowed in the base. Binary allows only 0 and 1, and octal stops at 7.
Frequently asked questions
How do I convert binary to decimal?
Give each digit a value that doubles from right to left (1, 2, 4, 8, …) and add up the ones where the digit is 1. For 1101 that is 8 + 4 + 1 = 13. Or type the binary number here and read the decimal box.
Why do programmers use hexadecimal?
One hex digit matches exactly four bits, so a byte is always two hex digits. It is much shorter and easier to read than binary.
Is there a limit on the size of the number?
No practical limit. The tool uses exact big-integer arithmetic, so numbers with hundreds of digits convert without rounding errors.
Can it convert fractions or decimals like 10.5?
Not here. This tool converts whole numbers (integers). It will tell you if a character is not valid in the base you chose.
People also search for this as: binary to decimal converter, decimal to binary, hex to decimal converter, decimal to hexadecimal, octal converter, base converter.
Sources and further reading
Formulas on this page are checked by automated tests against independent references. See how we test our tools.