How to convert decimal to binary
- Type your numbers into Input, one per line. Thousands separators like 1,000 are fine.
- The binary version of each number appears in the output.
- Tick Group binary digits in 4s to pad with leading zeros and split the bits into blocks, such as 0011 1110 1000.
Converting decimal to binary by hand
Divide by 2, write down the remainder, and keep dividing the result until you reach 0. The remainders read from bottom to top are the binary number. For 156:
| Division | Result | Remainder |
|---|---|---|
| 156 ÷ 2 | 78 | 0 |
| 78 ÷ 2 | 39 | 0 |
| 39 ÷ 2 | 19 | 1 |
| 19 ÷ 2 | 9 | 1 |
| 9 ÷ 2 | 4 | 1 |
| 4 ÷ 2 | 2 | 0 |
| 2 ÷ 2 | 1 | 0 |
| 1 ÷ 2 | 0 | 1 |
Reading the remainders upwards gives 10011100. To check it, add the place values of the 1s: 128 + 16 + 8 + 4 = 156.
Powers of two
The other way to convert is to subtract the largest power of two that fits, mark a 1 in that place, and repeat with what’s left. For 156 that’s 128, then 16, then 8, then 4. It helps to know the powers:
| Power | Decimal | Binary |
|---|---|---|
| 2⁰ | 1 | 1 |
| 2¹ | 2 | 10 |
| 2² | 4 | 100 |
| 2³ | 8 | 1000 |
| 2⁴ | 16 | 10000 |
| 2⁵ | 32 | 100000 |
| 2⁶ | 64 | 1000000 |
| 2⁷ | 128 | 10000000 |
| 2⁸ | 256 | 100000000 |
| 2⁹ | 512 | 1000000000 |
| 2¹⁰ | 1024 | 10000000000 |
Every power of two is a 1 followed by zeros, and one less than a power of two is all 1s: 255 is 11111111 and 1023 is 1111111111.