How to convert between bases
- Choose the base your number is written in: decimal, binary, octal, hex or any base from 2 to 36.
- Type or paste the number. Prefixes like
0xand separators like_are fine. - Read it in every other base at once, grouped for readability.
- Copy the one you need.
Decimal, binary, octal and hex from 0 to 16
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
| 0 | 0000 | 0 | 0 |
| 1 | 0001 | 1 | 1 |
| 2 | 0010 | 2 | 2 |
| 3 | 0011 | 3 | 3 |
| 4 | 0100 | 4 | 4 |
| 5 | 0101 | 5 | 5 |
| 6 | 0110 | 6 | 6 |
| 7 | 0111 | 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 |
Why programmers use hexadecimal
One hex digit is exactly four binary digits, so a byte is always two hex digits: 11111111 in binary is ff in hex. That makes hex a compact, readable way to write memory addresses, colors (#3b82f6) and binary data.
Common uses
- Hex values in logs and dumps. Convert memory addresses, error codes and byte values shown in hex into decimal, or back again, while debugging.
- Unix file permissions. Permissions such as 755 are octal. Convert them to binary to see exactly which read, write and execute bits are set.
- Checking homework answers. Work out a binary, octal or hex conversion by hand, then type the number in to check your answer in every base at once.
- Reading bit flags. Convert a flag value or register to binary with Group digits on, so you can see at a glance which bits are set.