Decimal to Binary: How to Convert Any Number Step by Step

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.

crossorigin="anonymous">

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

  1. Divide the number by 2.
  2. Write down the remainder (it is always 0 or 1).
  3. Divide the whole-number result by 2 again.
  4. Repeat until the result is 0.
  5. Read the remainders from bottom to top.

Here is 45 converted step by step:

DivisionResultRemainder
45 ÷ 2221
22 ÷ 2110
11 ÷ 251
5 ÷ 221
2 ÷ 210
1 ÷ 201

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.

PowerValue
201
212
224
238
2416
2532
2664
27128
28256
29512
2101024

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

DecimalBinary
101010
2511001
50110010
1001100100
12810000000
25511111111
256100000000
6111001100011

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.

Related Guides

Leave a Comment