To convert a decimal number to binary, divide it by 2 again and again, write down each remainder, and read the remainders from the last one to the first.
Decimal is base 10 and uses the digits 0 to 9. Binary is base 2 and uses only 0 and 1. Every position in a binary number is worth twice the position to its right (1, 2, 4, 8, 16 and so on), so converting a number means finding which of those place values add up to it.
Decimal to Binary Converter
Type a whole number to see it in binary. Use it to check the hand calculations below.
Method 1: Divide by 2 and Keep the Remainders
- Divide the number by 2.
- Write down the remainder (it is always 0 or 1).
- Divide the whole-number result by 2 again.
- Repeat until the result is 0.
- Read the remainders from bottom to top.
Here is 45 converted step by step:
| Division | Result | Remainder |
|---|---|---|
| 45 ÷ 2 | 22 | 1 |
| 22 ÷ 2 | 11 | 0 |
| 11 ÷ 2 | 5 | 1 |
| 5 ÷ 2 | 2 | 1 |
| 2 ÷ 2 | 1 | 0 |
| 1 ÷ 2 | 0 | 1 |
Reading the remainders from the bottom up gives 101101. Check it: 32 + 8 + 4 + 1 = 45.
Method 2: Subtract Powers of Two
This method works well for smaller numbers. Start with the largest power of two that fits, write a 1 in that position, subtract it, and carry on down the list. Write a 0 for any power that does not fit.
| Power | Value |
|---|---|
| 20 | 1 |
| 21 | 2 |
| 22 | 4 |
| 23 | 8 |
| 24 | 16 |
| 25 | 32 |
| 26 | 64 |
| 27 | 128 |
| 28 | 256 |
| 29 | 512 |
| 210 | 1024 |
Take 100. The largest power that fits is 64, which leaves 36. Then 32 fits, which leaves 4. 16 and 8 do not fit, 4 fits and leaves 0, and 2 and 1 are not needed. The pattern is 1 (64), 1 (32), 0 (16), 0 (8), 1 (4), 0 (2), 0 (1), so 100 in binary is 1100100.
Decimal to Binary Examples
| Decimal | Binary |
|---|---|
| 10 | 1010 |
| 25 | 11001 |
| 50 | 110010 |
| 100 | 1100100 |
| 128 | 10000000 |
| 255 | 11111111 |
| 256 | 100000000 |
| 611 | 1001100011 |
Notice that 128 and 256 are powers of two, so each is a single 1 followed by zeros. 255 is the largest number that fits in 8 bits, which is why you see it so often. See what 8-bit binary means for more on that.
Adding Leading Zeros
Computers store numbers in fixed-size groups, usually 4 or 8 bits, so you will often see zeros added on the left. The number 5 is 101, but in 8 bits it is written 00000101. The extra zeros do not change the value.
Converting Decimal Fractions
For the part after the decimal point, multiply by 2 instead of dividing. Take the whole-number part of each result as the next binary digit and keep going with the fraction that is left. For 0.625: 0.625 × 2 = 1.25 (digit 1), 0.25 × 2 = 0.5 (digit 0), 0.5 × 2 = 1.0 (digit 1). So 0.625 is 0.101 in binary. Some fractions, like 0.1, never end in binary (they repeat, as 1/3 does in decimal), which is why computers sometimes show tiny rounding errors.
Negative Numbers
Most computers store negative whole numbers using two’s complement. To write -5 in 8 bits, start with 5 (00000101), flip every bit (11111010), then add 1 to get 11111011.
Common Mistakes
- Reading the remainders in the wrong order. The first remainder is the last digit, so read from the bottom up.
- Stopping at 1 instead of 0. Keep dividing until the result is 0, so the final 1 is included.
- Skipping a position. A 0 still needs to be written wherever a power of two does not fit.
Frequently Asked Questions
What is 10 in binary?
10 in decimal is 1010 in binary (8 + 2).
What is 255 in binary?
255 is 11111111, all eight bits set to 1.
How many bits does a number need?
A number needs one more bit than the position of its largest power of two. For example, 100 needs 7 bits because 64 is the 7th position. Eight bits cover 0 to 255.
How do I convert binary back to decimal?
Add up the place values wherever there is a 1. Our guide to binary to decimal walks through it.