Number Base Converter (Binary, Octal, Decimal, Hex)
Enter one number to see it in binary, octal, decimal and hexadecimal at once. Binary is grouped in fours.
Prefixes such as 0x or 0b and spaces are ignored. For negative numbers use the two's complement calculator.
How the conversion works
To go from decimal to binary, keep dividing by 2 and read the remainders from bottom to top. To go from binary to hex, split the bits into groups of four from the right and turn each group into one digit 0–F (1100 1010 → CA). Octal uses groups of three.
Worked example: 202 in binary, hex and octal
- Divide by 2 repeatedly and write down the remainders: 202 ÷ 2 = 101 … 0, 101 ÷ 2 = 50 … 1, 50 ÷ 2 = 25 … 0, 25 ÷ 2 = 12 … 1, 12 ÷ 2 = 6 … 0, 6 ÷ 2 = 3 … 0, 3 ÷ 2 = 1 … 1, 1 ÷ 2 = 0 … 1
- Read the remainders from bottom to top: 1100 1010
- Split into groups of four for hex: 1100 = C, 1010 = A → 0xCA
- Split into groups of three for octal: 011 001 010 → 0o312
Number bases from 0 to 15
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
| 0 | 0000 | 0 | 0 |
| 1 | 0001 | 1 | 1 |
| 2 | 0010 | 2 | 2 |
| 3 | 0011 | 3 | 3 |
| 4 | 0100 | 4 | 4 |
| 5 | 0101 | 5 | 5 |
| 6 | 0110 | 6 | 6 |
| 7 | 0111 | 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 |
Frequently asked questions
How do I convert binary to hexadecimal quickly?
Split the binary number into groups of four bits from the right and replace each group with one hex digit: 1100 1010 becomes CA. Pad the leftmost group with zeros if needed.
Why do programmers use hexadecimal?
One hex digit is exactly four bits, so a byte is always two hex digits. It is far easier to read 0xCA than 11001010 while still mapping directly onto the bits.