A number base is simply how many digits are available before you carry into the next column. Decimal has ten, binary has two, hexadecimal has sixteen. The underlying quantity never changes — 255, 0xFF and 11111111 are the same number wearing different clothes — but the representation you choose determines how readable it is for the job at hand.
Programmers reach for hexadecimal because it maps cleanly onto binary: each hex digit is exactly four bits, so a byte is always two hex characters. That property is why memory addresses, colour codes and byte dumps are written in hex rather than decimal.
The same values across bases
| Decimal | Binary | Octal | Hexadecimal |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 8 | 1000 | 10 | 8 |
| 10 | 1010 | 12 | A |
| 15 | 1111 | 17 | F |
| 16 | 10000 | 20 | 10 |
| 64 | 1000000 | 100 | 40 |
| 255 | 11111111 | 377 | FF |
| 1024 | 10000000000 | 2000 | 400 |
Converting by hand
- To decimal: multiply each digit by the base raised to its position, counting from zero on the right. Binary 1101 is 8 + 4 + 0 + 1 = 13.
- From decimal: divide repeatedly by the base and read the remainders bottom-up. 13 ÷ 2 gives remainders 1, 0, 1, 1 → 1101.
- Binary to hex: group the bits in fours from the right and convert each group. 1101 0110 → D6.
- Binary to octal: the same trick with groups of three, since 8 is 2³.
Where each base shows up
- Binary: hardware registers, bit flags, permission masks, network subnet masks.
- Octal: Unix file permissions, where 755 encodes three sets of three bits.
- Hexadecimal: memory addresses, colour codes such as #FF5733, MAC addresses, hash digests.
- Base 36: short URL identifiers, which use all ten digits plus the twenty-six letters.
Prefixes that tell you the base
Most languages mark the base in the literal itself: 0b for binary, 0o or a leading zero for octal, and 0x for hexadecimal. An unmarked number is decimal. This matters more than it looks — in C and JavaScript a leading zero has historically meant octal, so 010 evaluates to 8, a bug that has caught out generations of programmers writing zero-padded values.
Related tools
- Data Storage Converter — bytes, kibibytes and the 1000/1024 problem
- Color Converter — hex codes are base 16 in practice
- Scientific Calculator
- Browse all free tools