How to Convert Between Binary, Decimal, Octal and Hexadecimal
Learn how number bases work and how to convert between binary, octal, decimal and hexadecimal by hand, with examples such as 255 and 2026.

Computers store everything as binary, programmers read it as hexadecimal and people think in decimal. Moving between these number systems is a basic skill in computing, electronics and networking. The free Number Base Converter converts instantly and handles very large numbers. This guide shows how to do it by hand.
Quick answer
The decimal number 255 is 11111111 in binary, 377 in octal and FF in hexadecimal. The number 2026 is 11111101010 in binary and 7EA in hexadecimal.
The Number Base Converter showing one number in several bases.
What is a base?
The base, or radix, is how many different digits a system uses before it carries to the next place.
| System | Base | Digits | Common use |
|---|---|---|---|
| Binary | 2 | 0 1 | Computers, logic |
| Octal | 8 | 0 to 7 | Unix file permissions |
| Decimal | 10 | 0 to 9 | Everyday counting |
| Hexadecimal | 16 | 0 to 9, A to F | Colours, memory, MAC addresses |
In hexadecimal, A = 10, B = 11, C = 12, D = 13, E = 14 and F = 15.
Binary to decimal
Each position is a power of 2, counting from the right starting at 1, 2, 4, 8, 16 and so on. For 1101:
1 x 8 + 1 x 4 + 0 x 2 + 1 x 1 = 13.
Decimal to binary
Divide by 2 repeatedly and write the remainders from the bottom up. For 13:
- 13 / 2 = 6 remainder 1
- 6 / 2 = 3 remainder 0
- 3 / 2 = 1 remainder 1
- 1 / 2 = 0 remainder 1
Reading from the last remainder to the first: 1101.
Hexadecimal shortcuts
One hexadecimal digit equals exactly four binary digits, which is why hex is used as a compact way of writing binary.
| 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 |
To convert 7EA to binary, write each digit as four bits: 0111 1110 1010, which is 11111101010 once the leading zero is dropped.
Where you will meet other bases
- Colours on the web: #2563EB is three hexadecimal bytes for red, green and blue. See the Color Converter.
- IP and MAC addresses, and memory addresses in debugging.
- Unix permissions: chmod 755 is octal.
- Character codes: the letter A is 65 decimal, 41 in hex. See the ASCII Table.
Tips
- Group binary digits in fours from the right when converting to hex.
- Remember powers of two: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024.
- Write the base as a subscript or prefix to avoid confusion: 0x for hex, 0b for binary.
- Use the converter to check your work, not to replace the practice.
Frequently asked questions
Why does hexadecimal use letters? Because it needs 16 symbols, and digits only go to 9.
What is the largest value in a byte? 255, which is FF in hex or 11111111 in binary.
Does the converter accept negative numbers? Yes, put a minus sign in front.
Next step
Convert your own number with the Number Base Converter. For text and encodings, try the Base64 Text Converter.


