Number Base Converter
Convert whole numbers between binary, octal, decimal, hexadecimal and any base from 2 to 36, and see the method step by step.
In binary
10011100₂
156₁₀ = 10011100₂.
- Binary
- 10011100
- Octal
- 234
- Decimal
- 156
- Hex
- 9C
Show me how
Why does this work?
All steps as text
Tip: press ← and → to move between steps, or click any step.
How base conversion works
- To decimal: each place is worth a power of the base. Multiply each digit by its place value and add: FF in hex is 15 × 16 + 15 × 1 = 255.
- From decimal: divide by the new base again and again and keep the remainders. Read them from the bottom up: 255 ÷ 16 = 15 remainder 15, then 15 ÷ 16 = 0 remainder 15, so 255 = FF.
- Between binary, octal and hex: group the bits in threes (octal) or fours (hex). 11111111 = 1111 1111 = FF.
- Between any other two bases, go through decimal: first to decimal, then from decimal.
Hexadecimal
Hex (base 16) needs 16 digits, so after 0 to 9 it uses letters: A = 10, B = 11, C = 12, D = 13, E = 14 and F = 15. One hex digit is exactly 4 bits, and two make a byte, from 00 to FF (255). That is why hex is everywhere in computing: web colors like #FF8800 are three bytes (red 255, green 136, blue 0), and memory addresses are written in hex.
Octal and other bases
Octal (base 8) uses the digits 0 to 7, and each octal digit is 3 bits. You may meet it in Unix file permissions: chmod 755 means 111 101 101, read, write and run for the owner (7) and read and run for everyone else (5). Bases above 16 carry on with letters up to Z = 35, so base 36 uses every digit and letter; it is used for short codes and IDs.
0 to 16 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 |
Questions
What is 255 in hex?
FF. 255 = 15 × 16 + 15, and the hex digit for 15 is F. It is also 11111111 in binary: one full byte.
How do I convert hex to binary?
Write each hex digit as 4 bits: 9C = 1001 1100. Going back, group the bits in fours from the right.
Can I type 0x, 0b or # in front?
Yes: 0x1F and #1F work for hex, 0b1011 for binary and 0o17 for octal. Spaces and underscores are ignored, and lower-case letters are fine.
How big a number can I convert?
Whole numbers from 0 up to 18,446,744,073,709,551,615, the largest number that fits in 64 bits (FFFFFFFFFFFFFFFF in hex).
Was this calculator helpful?