We count in base 10 because we have ten fingers, but computers work in base 2, and programmers often use base 16 or base 8 as shorthand. Converting between these systems is a daily task in programming, networking and electronics. Our binary and hex converter turns a number in any of the four common bases into all the others at once. This guide explains how each system works and how to convert by hand.
How to use the converter
- Number: type the value.
- Input base: binary, octal, decimal or hex.
With the default 255 in decimal, the results are:
- Hexadecimal: FF
- Binary: 11111111
- Octal: 377
- Decimal: 255
Enter 1101 as binary and you get decimal 13, hex D and octal 15.
The four common bases
| Base | Name | Digits used |
|---|---|---|
| 2 | Binary | 0, 1 |
| 8 | Octal | 0 to 7 |
| 10 | Decimal | 0 to 9 |
| 16 | Hexadecimal | 0 to 9, then A to F |
In hex, A = 10, B = 11, C = 12, D = 13, E = 14 and F = 15.
Place value
Every base works the same way: each position is worth the base raised to a power, counting from 0 on the right.
Decimal 255: 2 × 10² + 5 × 10¹ + 5 × 10⁰ = 200 + 50 + 5.
Binary 1101: 1 × 2³ + 1 × 2² + 0 × 2¹ + 1 × 2⁰ = 8 + 4 + 0 + 1 = 13.
Hex FF: 15 × 16¹ + 15 × 16⁰ = 240 + 15 = 255.
Octal 377: 3 × 64 + 7 × 8 + 7 × 1 = 192 + 56 + 7 = 255.
Converting decimal to another base
Divide repeatedly by the new base and write down the remainders. Read them from the bottom up.
Decimal 13 to binary:
- 13 ÷ 2 = 6 remainder 1
- 6 ÷ 2 = 3 remainder 0
- 3 ÷ 2 = 1 remainder 1
- 1 ÷ 2 = 0 remainder 1
Reading upward: 1101.
Decimal 200 to hex: 200 ÷ 16 = 12 remainder 8, and 12 ÷ 16 = 0 remainder 12 (C). Reading upward: C8.
Shortcut between binary and hex
Each hex digit is exactly four binary digits, so you can convert in groups without going through decimal.
| Hex | Binary | Hex | Binary |
|---|---|---|---|
| 0 | 0000 | 8 | 1000 |
| 1 | 0001 | 9 | 1001 |
| 2 | 0010 | A | 1010 |
| 3 | 0011 | B | 1011 |
| 4 | 0100 | C | 1100 |
| 5 | 0101 | D | 1101 |
| 6 | 0110 | E | 1110 |
| 7 | 0111 | F | 1111 |
Binary 1011 0110 splits into 1011 (B) and 0110 (6), giving B6. Octal works the same way with groups of three bits: 11 111 111 is 3 7 7.
Where each base is used
- Binary: how computers store everything. Each bit is on or off. The binary calculator does arithmetic and bitwise operations directly in base 2.
- Hexadecimal: a compact way to write binary. Web colours (#FF8800), memory addresses, MAC addresses and byte values all use hex. The hex calculator adds and multiplies in base 16.
- Octal: still used for Unix file permissions, such as chmod 755 (rwx r-x r-x).
- Decimal: everyday human counting.
Useful values to remember
- 1 byte = 8 bits, ranging from 0 to 255 (00 to FF in hex).
- 2¹⁰ = 1,024, and 2¹⁶ = 65,536 (FFFF + 1).
- An IPv4 address is four bytes, each 0 to 255. The IP subnet calculator shows the binary masks behind subnetting.
- A web colour like #3366CC has red 0x33 = 51, green 0x66 = 102, blue 0xCC = 204.
Tips
- Prefixes help avoid confusion: 0b for binary (0b1101), 0x for hex (0xFF), 0o or a leading 0 for octal.
- Hex letters are not case-sensitive: ff and FF are the same.
- Group long binary numbers in fours for readability.
Frequently asked questions
Why do computers use binary?
Electronic circuits are most reliable with two states, on and off. Binary maps directly onto those states.
Why do programmers use hexadecimal?
One hex digit represents exactly four bits, so a byte is always two hex digits. It is far shorter and easier to read than binary.
How do I convert hex to decimal quickly?
Multiply each digit by 16 raised to its position and add. For 2F: 2 × 16 + 15 = 47.
Can the converter handle large numbers?
Yes. It converts large whole numbers exactly, well beyond the range of a single byte.
Try it yourself
Run your own numbers with our free tool: Binary & hex converter. No sign-up, and it works on any device.