Decimal to Binary Converter
Convert decimal to binary with every step shown as a repeated division by 2. Group the bits in fours or bytes, convert huge numbers exactly and get the two's complement bits of negative numbers.
Whole numbers of any size. Commas and spaces are ignored, and a minus sign is allowed.
| Binary | | |
|---|---|---|
| Octal | | |
| Decimal | | |
| Hex | | |
| Bit length | |
Show steps
Divide the decimal number by the new base again and again until the quotient is 0. The remainders, read from the bottom up, are the digits of the result.
| Division | Quotient | Remainder | Digit |
|---|
Two's complement view (signed numbers)
Auto picks the smallest of 8, 16, 32 or 64 bits that holds the number as a signed value.
| Width | | |
|---|---|---|
| Bits | | |
| Hex | | |
| Unsigned | | |
| Signed | |
Convert Decimal Numbers to Binary Online
Whether you are studying for an exam, setting a bit mask or writing a byte to hardware, you often need a number in binary. This decimal to binary converter writes any whole number in base 2 as you type it.
The steps table shows the repeated division by 2 for your exact number, so you can follow the method line by line.
How to use the decimal to binary converter
- Type a decimal number, for example
156. - Copy the binary result,
10011100. Pick "Groups of 4 bits" to get1001 1100. - Follow the steps to see each division, or open the two's complement view for a fixed width such as 8 or 16 bits.
How to convert decimal to binary: divide by 2
Divide the number by 2 and write down the remainder, which is always 0 or 1. Divide the quotient by 2 again and repeat until the quotient is 0. The remainders read from the bottom up are the binary digits. For 156:
| Division | Quotient | Remainder |
|---|---|---|
| 156 ÷ 2 | 78 | 0 |
| 78 ÷ 2 | 39 | 0 |
| 39 ÷ 2 | 19 | 1 |
| 19 ÷ 2 | 9 | 1 |
| 9 ÷ 2 | 4 | 1 |
| 4 ÷ 2 | 2 | 0 |
| 2 ÷ 2 | 1 | 0 |
| 1 ÷ 2 | 0 | 1 |
Reading the remainders upward gives 10011100. Check it: 128 + 16 + 8 + 4 = 156.
The subtraction method
For smaller numbers it can be quicker to subtract powers of 2. Find the largest power of 2 that fits, subtract it and repeat. For 100: 64 fits (36 left), then 32 (4 left), then 4 (0 left). Put a 1 under 64, 32 and 4 and a 0 under every other place value: 1100100.
Decimal to binary table (0–16)
| Decimal | Binary | 4-bit / 8-bit form |
|---|---|---|
| 0 | 0 | 0000 |
| 1 | 1 | 0001 |
| 2 | 10 | 0010 |
| 3 | 11 | 0011 |
| 4 | 100 | 0100 |
| 5 | 101 | 0101 |
| 6 | 110 | 0110 |
| 7 | 111 | 0111 |
| 8 | 1000 | 1000 |
| 9 | 1001 | 1001 |
| 10 | 1010 | 1010 |
| 11 | 1011 | 1011 |
| 12 | 1100 | 1100 |
| 13 | 1101 | 1101 |
| 14 | 1110 | 1110 |
| 15 | 1111 | 1111 |
| 16 | 10000 | 0001 0000 |
More decimal to binary examples
| Decimal | Binary | Bits |
|---|---|---|
| 42 | 101010 | 6 |
| 99 | 1100011 | 7 |
| 127 | 1111111 | 7 |
| 200 | 11001000 | 8 |
| 500 | 0001 1111 0100 | 9 |
| 1,023 | 0011 1111 1111 | 10 |
| 4,096 | 0001 0000 0000 0000 | 13 |
Negative numbers in binary
With a minus sign, the converter writes the magnitude in binary and keeps the sign, so −13 becomes -1101. Computers instead use two's complement: write 13 in the chosen width (00001101), flip every bit (11110010) and add 1 to get 11110011. The two's complement view does this for 8, 16, 32 or 64 bits.
A width of n bits holds signed values from −2n−1 to 2n−1 − 1, so 8 bits cover −128 to 127.
How many bits does a number need?
n bits store unsigned values from 0 to 2n − 1: 4 bits reach 15, 8 bits 255, 16 bits 65,535 and 32 bits 4,294,967,295.
Only whole numbers are supported. Fractions such as 0.1 have no exact binary form (they repeat forever), which is why 0.1 + 0.2 is not exactly 0.3 in most programming languages.
Frequently Asked Questions
Common questions about converting decimal numbers to binary.
Divide by 2 repeatedly and write down the remainders, then read them from the last to the first. 13 gives remainders 1, 0, 1, 1, so 13 is 1101 in binary.
10 is 1010 in binary: 8 + 2.
255 is 11111111, eight 1s. It is the largest value of one byte.
100 is 1100100, which is 64 + 32 + 4.
In two's complement every bit is 1: 11111111 in 8 bits, or sixteen 1s in 16 bits. With a plain minus sign it is -1.
Groups of 4 are easier to read and each group is exactly one hex digit, so 1001 1100 is 9C in hex.
Use the binary to decimal converter, which adds up the powers of 2 for you.