Computers don't think in decimal like us: they use binary, and programmers also handle hexadecimal and octal daily. Understanding how these bases work and how to convert between them is fundamental in computing. This guide explains it without complicated math.
What is a number base
The base of a number system indicates how many distinct symbols it uses to represent numbers:
- Decimal (base 10): ours. Ten symbols: 0-9.
- Binary (base 2): computers'. Two symbols: 0 and 1.
- Octal (base 8): eight symbols: 0-7.
- Hexadecimal (base 16): sixteen symbols: 0-9 and A-F (where A=10, B=11... F=15).
In any base, each position is worth the base raised to its position. In decimal, 345 = 3×100 + 4×10 + 5×1. Binary works the same, but with powers of 2.
Why computing uses binary
A computer runs on transistors that have only two states: on (1) or off (0). That's why all information — numbers, text, images — is internally represented in binary. A single binary digit is a bit; eight bits are a byte.
Why programmers use hexadecimal
Binary is awkward to read: 11111111 is eight digits to represent 255. Hexadecimal is much more compact because each hex digit equals exactly 4 bits. So 11111111 in binary is FF in hexadecimal. That's why you'll see hex in:
- CSS colors:
#FF5733. - Memory addresses and dumps.
- Error codes and registers.
- MAC addresses and UUIDs.
How to convert between bases
Decimal to binary
Divide by 2 repeatedly and note the remainders bottom-up. 13 → 1101.
Binary to decimal
Add the powers of 2 at the positions with 1. 1101 = 8 + 4 + 0 + 1 = 13.
Binary to hexadecimal
Group the binary into blocks of 4 bits and convert each block. 1101 0011 → D3.
Hexadecimal to decimal
Multiply each digit by 16 raised to its position. D3 = 13×16 + 3 = 211.
Doing this by hand is error-prone. You can convert between binary, decimal, hexadecimal and octal instantly with the base converter on this site.
Quick examples
| Decimal | Binary | Hexadecimal | Octal |
|---|---|---|---|
| 8 | 1000 | 8 | 10 |
| 15 | 1111 | F | 17 |
| 16 | 10000 | 10 | 20 |
| 255 | 11111111 | FF | 377 |
| 256 | 100000000 | 100 | 400 |
Frequently asked questions
Why is 255 such a common number? It's the largest value of a byte (8 bits): 11111111. That's why RGB color channels go from 0 to 255.
What is 0x in programming? The 0x prefix indicates a number is in hexadecimal: 0xFF = 255. The 0b prefix indicates binary.
What is octal used for today? Less than before; it's seen mostly in Unix file permissions (chmod 755).
Is my data uploaded when converting? No, if you use a local converter. Everything happens in your browser.
Convert between binary, decimal, hexadecimal and octal instantly with the free base converter, 100% in your browser.