Decimal to Binary

Type a number and get its binary form, with the working written out two different ways.

Binary1001 1100
Hexadecimal9C
Try

Fixed-size binary

Padded with zeros to a set width. Negatives use two's complement.

Your working

Divide until the quotient reaches 0, then read the remainders from the bottom up

DivideQuotientRemainder

Method 1: keep dividing by 2

This is the method most classes teach, and it works on any number. Divide by 2, write down the remainder, and repeat with the quotient until you reach 0. Here it is for 156.

DivideQuotientRemainder
156 ÷ 2780
78 ÷ 2390
39 ÷ 2191
19 ÷ 291
9 ÷ 241
4 ÷ 220
2 ÷ 210
1 ÷ 201

Read the remainder column from the bottom up and you get 10011100.

The upward reading trips up nearly everyone at first. It makes sense once you see what each division does. A remainder of 1 means the number is odd, and only the rightmost bit can make a number odd, so the first remainder is the last bit. Dividing by 2 then removes that bit, and the next remainder reveals the one before it.

Method 2: subtract powers of 2

Many people find this easier to do in their head. Write out the powers of 2, go through them from largest to smallest, and take away each one that fits. A power that fits gets a 1, and one that doesn't gets a 0.

PowerLeft overFits?Bit
128156Yes, 28 left1
6428No0
3228No0
1628Yes, 12 left1
812Yes, 4 left1
44Yes, 0 left1
20No0
10No0

Read the bit column from the top down and you get the same answer, 10011100.

Which one should you use?

If your exam asks you to show the method, use whichever your teacher taught, which is usually division. For numbers under about 1,000, subtraction is quicker once you know the powers of 2. For anything big, type it in above.

Shortcuts worth knowing

Odd or even tells you the last bit

Odd numbers end in 1 and even numbers end in 0, so you can catch a wrong answer at a glance.

Powers of 2 are a 1 followed by zeros

64 is 1000000 and 1024 is 10000000000. The number of zeros is the power.

One less than a power of 2 is all ones

63 is 111111 and 255 is 11111111. That makes numbers close to them easy, because 250 is 255 minus 5, or 11111010.

Doubling adds a 0 on the end

13 is 1101, so 26 is 11010 and 52 is 110100. If you know a number's half, you're nearly done.

Decimal to binary chart

Select any number to see its working in the converter.

DecimalBinary
00
11
210
311
4100
5101
6110
7111
81000
91001
101010
111011
121100
131101
141110
151111
DecimalBinary
1610000
1710001
1810010
1910011
2010100
2110101
2210110
2310111
2411000
2511001
2611010
2711011
2811100
2911101
3011110
3111111

Bigger numbers you'll often see

DecimalBinary
50110010
641000000
1001100100
1271111111
12810000000
20011001000
25511111111
256100000000
500111110100
5121000000000
10001111101000
102410000000000
2048100000000000
40961000000000000
655351111111111111111

Negative numbers

On paper you can write −13 as -1101, and that's what the Binary row shows. Computers have no minus sign to store, so they use two's complement. Write the positive number at a fixed width, flip every bit, then add 1.

13 = 00001101. Flip = 11110010. Add 1 = 11110011, which is −13 in 8 bits

Fractions and decimal points

The converter above handles whole numbers only, but fractions are easy to do by hand. Keep multiplying the fraction by 2. Each time, the digit before the point becomes your next bit, and you carry on with what's left after the point.

0.625 × 2 = 1.25, so 1. 0.25 × 2 = 0.5, so 0. 0.5 × 2 = 1.0, so 1. Answer: 0.101

Unlike the division method, you read these bits from the top down. For a number like 6.625, convert each side of the point separately and join them to get 110.101.

Some fractions never finish. 0.1 repeats forever in binary, the way 1/3 does in decimal, so computers store a close approximation. That's why adding 0.1 and 0.2 in many programming languages gives 0.30000000000000004.

Where answers usually go wrong

Reading the remainders from the top down

This gives the bits in reverse. For 156 you'd write 00111001, which is 57.

Stopping one step early

Keep going until the quotient is 0. The final step, 1 ÷ 2, always leaves a remainder of 1, and that's your leftmost bit.

Dropping zeros from the middle

Every power below your starting point needs a digit. Leave out the zeros in the middle of 1001 and 9 becomes 3.

Not checking the answer

Add up the place values of your 1s. If they don't come back to your starting number, something slipped. It takes ten seconds.

Try these yourself

Work each one out on paper before you open it.

What is 37 in binary?

100101. That's 32 + 4 + 1, and because 37 is odd it ends in 1.

What is 100 in binary?

1100100. That's 64 + 32 + 4. It takes seven bits, since 64 is the largest power of 2 that fits.

What is 250 in binary?

11111010. The quick way is to start from 255, which is all ones, and take away 5 (the 4 and the 1).

Common questions

What is 10 in binary?

It's 1010, because 8 + 2 = 10. Don't confuse this with the binary number 10, which equals 2.

How many bits does a number need?

Find the smallest n where 2 to the power n is bigger than your number. With 8 bits you can go up to 255, and with 16 bits up to 65,535.

Do zeros at the front change the value?

No. 1101 and 00001101 are both 13. The zeros only pad the number to a fixed width, the same way 007 is still 7.

How large a number can I enter?

Up to 16,384 bits, which is about 4,900 decimal digits, with no rounding. The step-by-step working is shown up to 32 bits, or a little over 4 billion.

Is my number sent anywhere?

No. The conversion runs in your browser, so nothing you type reaches our server. A link you copy can contain the number, so only share it if you're happy for others to see it.