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.
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.
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
| Decimal | Binary | Bits |
|---|---|---|
| 0 | 0 | 1 |
| 1 | 1 | 1 |
| 2 | 10 | 2 |
| 3 | 11 | 2 |
| 4 | 100 | 3 |
| 5 | 101 | 3 |
| 6 | 110 | 3 |
| 7 | 111 | 3 |
| 8 | 1000 | 4 |
| 9 | 1001 | 4 |
| 10 | 1010 | 4 |
| 11 | 1011 | 4 |
| 12 | 1100 | 4 |
| 13 | 1101 | 4 |
| 14 | 1110 | 4 |
| 15 | 1111 | 4 |
| 16 | 10000 | 5 |
| 17 | 10001 | 5 |
| 18 | 10010 | 5 |
| 19 | 10011 | 5 |
| 20 | 10100 | 5 |
| 32 | 100000 | 6 |
| 64 | 1000000 | 7 |
| 100 | 1100100 | 7 |
| 127 | 1111111 | 7 |
| 128 | 10000000 | 8 |
| 255 | 11111111 | 8 |
| 256 | 100000000 | 9 |
| 1000 | 1111101000 | 10 |
| 1023 | 1111111111 | 10 |
| 1024 | 10000000000 | 11 |
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.
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.
| Bits | Unsigned range | Signed range |
|---|---|---|
| 8 | 0 to 255 | −128 to 127 |
| 16 | 0 to 65,535 | −32,768 to 32,767 |
| 32 | 0 to 4,294,967,295 | −2,147,483,648 to 2,147,483,647 |
| 64 | 0 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.
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.