How number base conversion works
A number base, or radix, is simply how many distinct digits a system uses before it rolls over to the next place. Decimal (base 10) uses ten digits, 0–9. Binary (base 2) uses just 0 and 1, octal (base 8) uses 0–7, and hexadecimal (base 16) uses 0–9 plus A–F to stand for the values ten through fifteen. The same quantity can be written in all four bases.
To read a number in any base, multiply each digit by the base raised to its position (starting at 0 on the right) and add the results. To go the other way — from decimal into another base — repeatedly divide by the target base and read the remainders from last to first. Computers favour binary because a wire is either on or off, and hexadecimal is popular because each hex digit packs exactly four bits.
Reference note: conversions use standard positional notation. Values up to 9,007,199,254,740,991 (the safe integer limit) are handled with regular numbers; very large binary and hexadecimal inputs fall back to BigInt so no precision is lost.
Conversion table (0–16)
| Decimal | Binary | Hex | Octal |
|---|---|---|---|
| 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 | 8 | 10 |
| 9 | 1001 | 9 | 11 |
| 10 | 1010 | A | 12 |
| 11 | 1011 | B | 13 |
| 12 | 1100 | C | 14 |
| 13 | 1101 | D | 15 |
| 14 | 1110 | E | 16 |
| 15 | 1111 | F | 17 |
| 16 | 10000 | 10 | 20 |
Frequently asked questions
- How do I convert decimal to binary?
- Repeatedly divide the decimal number by 2 and record each remainder, then read the remainders from last to first. For example 13 gives remainders 1, 0, 1, 1, so 13 is 1101 in binary. The tool above does this instantly as you type.
- What is 255 in binary and hex?
- Decimal 255 is 11111111 in binary (eight ones — the most that fits in one byte), FF in hexadecimal and 377 in octal. It is the maximum value of an unsigned 8-bit number.
- How do I convert binary to decimal?
- Multiply each binary digit by its place value (a power of two) and add them up. Reading 1101 from the right: 1×1 + 0×2 + 1×4 + 1×8 = 13.
- What is hexadecimal used for?
- Hexadecimal (base 16) is a compact shorthand for binary — each hex digit equals four bits. It is used for CSS colours like #FF8800, memory addresses, byte values and low-level debugging.
- How do I convert hex to binary?
- Replace each hex digit with its four-bit binary equivalent. F is 1111 and 8 is 1000, so hex F8 becomes 11111000. The mapping is exact because 16 is 2 to the power 4.
- What is octal?
- Octal is base 8 and uses only the digits 0–7. Each octal digit equals three binary bits, which is why it appears in Unix file permissions such as 755.