Decimal to Binary Converter
Conversion steps
| Division by 2 | Quotient | Remainder (Digit) | Bit # |
|---|
Memory layout (byte order)
Decimal
Decimal is the number system we use every day. It has ten digits, 0 to 9, and each place is worth ten times the place to its right. In 677, the 6 stands for 600, the 7 in the tens place for 70 and the last 7 for 7.
Binary
Binary has only two digits, 0 and 1, and each place is worth twice the place to its right. The places are 1, 2, 4, 8, 16, 32, 64, 128 and so on. So 1010 means 8 + 2, which is 10 in decimal. Computers use binary because digital circuits have two dependable states, off and on.
How to convert decimal to binary
- Divide the decimal number by 2.
- Write down the remainder (0 or 1) as the next binary digit.
- Replace the number with the quotient and repeat until the quotient is 0.
- Read the remainders from the last one to the first. That is the binary number.
Example: convert 125 to binary
| Division by 2 | Quotient | Remainder | Bit # |
|---|---|---|---|
| 125 ÷ 2 | 62 | 1 | 0 (LSB) |
| 62 ÷ 2 | 31 | 0 | 1 |
| 31 ÷ 2 | 15 | 1 | 2 |
| 15 ÷ 2 | 7 | 1 | 3 |
| 7 ÷ 2 | 3 | 1 | 4 |
| 3 ÷ 2 | 1 | 1 | 5 |
| 1 ÷ 2 | 0 | 1 | 6 (MSB) |
Reading the remainders from bit 6 down to bit 0 gives 12510 = 11111012.
Example: convert 25 to binary
| Division by 2 | Quotient | Remainder | Bit # |
|---|---|---|---|
| 25 ÷ 2 | 12 | 1 | 0 (LSB) |
| 12 ÷ 2 | 6 | 0 | 1 |
| 6 ÷ 2 | 3 | 0 | 2 |
| 3 ÷ 2 | 1 | 1 | 3 |
| 1 ÷ 2 | 0 | 1 | 4 (MSB) |
So 2510 = 110012.
Negative numbers and two's complement
Binary has no minus sign in computer memory. Negative whole numbers are stored in two's complement: write the positive number using a fixed number of bits, flip every bit, then add 1. For -5 in 8 bits, 5 is 00000101, the flipped value is 11111010, and adding 1 gives 11111011. The converter above shows this result automatically, using the smallest width of 8, 16, 32, 64 or more bits that fits the value.
Decimal to binary conversion table
| Decimal | Binary | Hex |
|---|---|---|
| 0 | 0 | 0 |
| 1 | 1 | 1 |
| 2 | 10 | 2 |
| 3 | 11 | 3 |
| 4 | 100 | 4 |
| 5 | 101 | 5 |
| 6 | 110 | 6 |
| 7 | 111 | 7 |
| 8 | 1000 | 8 |
| 9 | 1001 | 9 |
| 10 | 1010 | A |
| 11 | 1011 | B |
| 12 | 1100 | C |
| 13 | 1101 | D |
| 14 | 1110 | E |
| 15 | 1111 | F |
| 16 | 10000 | 10 |
| 17 | 10001 | 11 |
| 18 | 10010 | 12 |
| 19 | 10011 | 13 |
| 20 | 10100 | 14 |
| 21 | 10101 | 15 |
| 22 | 10110 | 16 |
| 23 | 10111 | 17 |
| 24 | 11000 | 18 |
| 25 | 11001 | 19 |
| 26 | 11010 | 1A |
| 27 | 11011 | 1B |
| 28 | 11100 | 1C |
| 29 | 11101 | 1D |
| 30 | 11110 | 1E |
| 31 | 11111 | 1F |
| 32 | 100000 | 20 |
| 64 | 1000000 | 40 |
| 128 | 10000000 | 80 |
| 256 | 100000000 | 100 |
FAQs
How do I convert decimal to binary?
Divide by 2 again and again, keep each remainder, and read the remainders from the last to the first. For example, 13 gives 1101.
What is 10 in binary?
10 in decimal is 1010 in binary, because 10 = 8 + 2.
How do I convert a negative number to binary?
Use two's complement. Write the positive value in a fixed number of bits, invert all the bits and add 1. The converter shows the result for you.
What is the largest decimal number in 8 bits?
Unsigned, it is 255 (11111111). Signed, an 8-bit number runs from -128 to 127.
What is the difference between big endian and little endian?
Big endian stores the most significant byte at the lowest address. Little endian stores the least significant byte there instead.
Does the converter work for text?
Yes. Choose Text in the From or To list. Text is converted as UTF-8 bytes, so letters, Hindi characters and emoji all work.
This tool is for general educational use. Everything is calculated in your browser and nothing you type is sent to a server.