Converting numbers between number systems is a foundational topic in computer science classes, and also a practical skill for programming. Let's walk through how to convert a decimal number to binary (and back) by hand, and when it's easier to just use a ready-made tool.
Converting a decimal number to binary
Divide the number by 2 repeatedly, writing down the remainder each time, until the quotient reaches zero. Then read the remainders from bottom to top.
Example for the number 13:
13 ÷ 2 = 6, remainder 1
6 ÷ 2 = 3, remainder 0
3 ÷ 2 = 1, remainder 1
1 ÷ 2 = 0, remainder 1
Reading the remainders bottom to top gives 1101. So decimal 13 equals binary 1101.
Converting a binary number to decimal
Multiply each binary digit by the corresponding power of two based on its position (right to left, starting at power 0), then add up the results.
For 1101:
1×2³ + 1×2² + 0×2¹ + 1×2⁰ = 8 + 4 + 0 + 1 = 13
Quick reference table
| Decimal | Binary |
|---|---|
| 0 | 0 |
| 1 | 1 |
| 2 | 10 |
| 5 | 101 |
| 10 | 1010 |
| 16 | 10000 |
| 255 | 11111111 |
What about octal and hexadecimal
The same conversion logic applies to any number system — only the base changes (8 for octal, 16 for hexadecimal with digits 0-9 and A-F). Hexadecimal shows up constantly in programming: color codes, memory addresses, debug dumps.
Converting online
Doing the division by hand is great for understanding the concept, but for large numbers and everyday use it's easier to reach for the number base converter — it converts between binary, octal, decimal, hexadecimal, and base36, handles large numbers, and validates that the digits you entered are correct for the chosen base.