Binary, decimal, hex and octal explained: converting by hand
Every number system is place value with a different base. This guide shows how to convert by hand between binary, decimal, hex and octal, and why computers use them.
Place value and the idea of a base
The decimal system uses base 10: ten digits (0 to 9), and each place is worth ten times the one to its right. The number 345 means 3 × 100 + 4 × 10 + 5 × 1.
Other bases work the same way with a different multiplier:
- Binary (base 2) uses only 0 and 1. Places are worth 1, 2, 4, 8, 16, 32 and so on.
- Octal (base 8) uses digits 0 to 7. Places are worth 1, 8, 64 and so on.
- Hexadecimal (base 16) uses 0 to 9 and then A to F for the values 10 to 15. Places are worth 1, 16, 256 and so on.
Computers store everything as on and off states, which is why binary is the native system. The others are shorthand: one hex digit stands for exactly four binary digits, and one octal digit stands for exactly three.
Binary to decimal
Write the place values under each bit and add up those where the bit is 1. For binary 101101:
| Place value | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|
| Bit | 1 | 0 | 1 | 1 | 0 | 1 |
32 + 8 + 4 + 1 = 45. The binary to decimal converter does the same for longer numbers.
Decimal to binary by repeated division
Divide by 2 repeatedly and record each remainder. Then read the remainders from the last one back to the first. For 45:
- 45 ÷ 2 = 22, remainder 1
- 22 ÷ 2 = 11, remainder 0
- 11 ÷ 2 = 5, remainder 1
- 5 ÷ 2 = 2, remainder 1
- 2 ÷ 2 = 1, remainder 0
- 1 ÷ 2 = 0, remainder 1
Reading the remainders upwards gives 101101, matching the result above. The same method works for any base: divide by 16 for hex or 8 for octal. The decimal to binary converter is handy for checking your work.
Hexadecimal
Hex digits after 9 are letters: A = 10, B = 11, C = 12, D = 13, E = 14, F = 15. To convert hex 2F to decimal, multiply each digit by its place value: 2 × 16 + 15 × 1 = 47. Hex FF is 15 × 16 + 15 = 255, the largest value that fits in one byte (8 bits).
To go from decimal to hex, divide by 16. For 200: 200 ÷ 16 = 12 remainder 8, and 12 is C, so 200 is C8. Try it with the hex to decimal converter.
Hex is common in web colours. A colour such as #FF8800 is three bytes, one each for red, green and blue: FF is 255 red, 88 is 136 green and 00 is 0 blue.
Shortcuts between binary, hex and octal
Because 16 and 8 are powers of two, you can convert by grouping bits instead of doing arithmetic.
- Binary to hex: group bits in fours from the right. 11001000 becomes 1100 and 1000, which are C and 8, so C8.
- Binary to octal: group bits in threes from the right. 11001000 padded to 011 001 000 gives 3, 1, 0, so 310.
- Hex to binary: replace each digit with its four bits. 2F is 0010 1111.
Decimal 200 is therefore 11001000 in binary, C8 in hex and 310 in octal. Octal is less common today, but it still appears in Unix file permissions. The permission value 755 is 7 × 64 + 5 × 8 + 5 = 493 in decimal, and each octal digit maps to three read, write and execute bits. The octal to decimal converter covers these values.
Common mistakes
- Reading remainders in the wrong order when dividing. They must be read bottom to top.
- Treating hex letters as plain text. B means 11, not a word.
- Forgetting that places count from the right, starting at zero.
- Mixing up digits that do not exist in a base, for example the digit 8 in octal or 2 in binary.
- Dropping leading zeros when grouping bits, which shifts the groups.
Frequently asked questions
How do I convert binary to decimal?
Add the place values (1, 2, 4, 8 and so on from the right) wherever the bit is 1. Binary 101101 is 32 + 8 + 4 + 1 = 45.
How do I convert decimal to binary?
Divide by 2 repeatedly, note each remainder, and read the remainders from last to first. For 45 that gives 101101.
Why do programmers use hexadecimal?
One hex digit equals exactly four bits, so long binary values become short and easy to read. Two hex digits describe one byte, which is why colours, memory addresses and byte values are often written in hex.
What is FF in decimal?
255. It is 15 × 16 + 15, the largest value that fits in one byte.
More guides
- Compound interest explained: the formula, a worked table and the Rule of 72
- How to calculate GPA: weighted, unweighted and the 4.0 scale
- BMI: what it measures, how to calculate it and where it falls short
- Discounts, sales tax and tips: how to calculate them correctly
- All guides
Paul Digital guides are written from hands-on testing of the tools on this site and are reviewed when platforms or formats change. Requirements set by exam boards, governments and apps vary and change over time, so always check the official instructions for your case. Spotted an error? Email askpaulonline@gmail.com.