Cipher Utility

Decimal to Binary Converter

E-09

Decimal numbers to binary, with every division by 2 shown. Runs in your browser; nothing is sent anywhere.

Bits:
Group:
Spaces:
Signed:

Division by 2

How to convert by hand

  1. Divide the number by 2.
  2. Write down the remainder, 0 or 1.
  3. Divide the quotient by 2 again.
  4. Stop when the quotient is 0.
  5. Read the remainders from last to first.

Worked example

13 = ?

13 ÷ 2 = 6  r 1
 6 ÷ 2 = 3  r 0
 3 ÷ 2 = 1  r 1
 1 ÷ 2 = 0  r 1

Read the remainders upwards:

13 = 1101

Cipher Utility reference card Catalog no. E-09

How to convert decimal to binary

Divide the number by 2 and write down the remainder, which is always 0 or 1. Then divide the quotient by 2 and write down that remainder too. Keep going until the quotient is 0. The remainders, read from the last one back to the first, are the binary number.

156 ÷ 2 = 78 remainder 0 78 ÷ 2 = 39 remainder 0 39 ÷ 2 = 19 remainder 1 19 ÷ 2 = 9 remainder 1 9 ÷ 2 = 4 remainder 1 4 ÷ 2 = 2 remainder 0 2 ÷ 2 = 1 remainder 0 1 ÷ 2 = 0 remainder 1 read upwards: 10011100

The first remainder is the last binary digit, which is why you read them backwards. The table under the converter shows these steps for any number you type, with the numbers in a row from left to right.

The subtraction method

You can also work down from the largest power of 2. Find the biggest power of 2 that fits into the number, write 1 for it and subtract it. Then go through the smaller powers in order. Write 1 when the power fits into what is left, and 0 when it does not.

128 fits in 156 1 156 − 128 = 28 64 too big 0 32 too big 0 16 fits in 28 1 28 − 16 = 12 8 fits in 12 1 12 − 8 = 4 4 fits in 4 1 4 − 4 = 0 2 too big 0 1 too big 0 156 = 10011100

Both methods give the same answer. Subtraction is quicker in your head once you know the powers of 2, and the binary to decimal page has a table of them.

Decimal to binary table

DecimalBinaryBits
001
111
2102
3112
41003
51013
61103
71113
810004
910014
1010104
1110114
1211004
1311014
1411104
1511114
16100005
17100015
18100105
19100115
20101005
321000006
6410000007
10011001007
12711111117
128100000008
255111111118
2561000000009
1000111110100010
1023111111111110
10241000000000011

Each power of 2 is a 1 followed by zeros, and one less than a power of 2 is all ones. That makes 127, 255 and 1023 easy to spot.

Negative numbers in binary

Computers store negative whole numbers in two’s complement. To find −5 in 8 bits, write 5 in binary, flip every bit and add 1.

5 00000101 flip 11111010 add 1 11111011

So −5 in 8-bit binary is 11111011. The width matters: in 16 bits the same number is 1111111111111011. With Bits set to Auto, a negative number gets the smallest width of 8, 16, 32, 64 bits or more that holds it. Pick a width to use a fixed one.

BitsUnsigned rangeSigned range
80 to 255−128 to 127
160 to 65,535−32,768 to 32,767
320 to 4,294,967,295−2,147,483,648 to 2,147,483,647
640 to 18,446,744,073,709,551,615−9,223,372,036,854,775,808 to 9,223,372,036,854,775,807

On paper, a minus sign in front of the digits, as in −101, is also correct. Most computers use two’s complement for whole numbers because the same adding circuit then works for negative and positive numbers.

Decimal fractions in binary

For the part after the decimal point, multiply by 2 instead of dividing. The whole part of each result, 0 or 1, is the next binary digit. Keep multiplying what is left after the point until it reaches 0.

0.625 × 2 = 1.25 digit 1 0.25 × 2 = 0.5 digit 0 0.5 × 2 = 1.0 digit 1 0.625 = 0.101 in binary

Some fractions never reach 0. 0.1 becomes 0.000110011001100… with 0011 repeating forever, the same way 1/3 never ends in decimal. The converter stops after 32 binary places and tells you which digits repeat. This is also why 0.1 + 0.2 gives 0.30000000000000004 in JavaScript, Python and most other languages: neither 0.1 nor 0.2 can be stored exactly in binary.

How many bits does a number need?

Find the largest power of 2 that is not bigger than the number. If that power is 2 to the n, the number needs n + 1 bits. 1000 lies between 512 (2 to the 9) and 1024, so it needs 10 bits. Every number from 128 to 255 needs 8 bits, and every number from 256 to 511 needs 9.

Converting text instead of numbers

Words such as “I love you” are not numbers, so this converter cannot read them. Each letter first has to be turned into its character code, and the Text to Binary converter does that in one step.

Questions about decimal to binary

What is 10 in binary?

1010. 10 is 8 + 2, so the bits for 8 and 2 are 1 and the bits for 4 and 1 are 0.

What is 100 in binary?

1100100. 100 is 64 + 32 + 4.

What is 255 in binary?

11111111, eight ones. 255 is the largest number that fits in 8 bits, which is why it shows up so often in colour values and IP address masks.

What is 1000 in binary?

1111101000. 1000 is 512 + 256 + 128 + 64 + 32 + 8, so it needs 10 bits.

How do you write -1 in binary?

In two's complement, -1 is all ones: 11111111 in 8 bits and sixteen ones in 16 bits. Adding 1 to it overflows to all zeros, which is 0.

Is my number sent to a server?

No. The conversion runs in your browser with JavaScript, and nothing you type leaves your device.