Free tool
Decimal to Binary Converter
Convert a decimal number to binary with the repeated division by 2 shown, pad it to 8, 16, 32 or 64 bits, and see negative numbers in two's complement.
- Binary
- –
- Octal
- –
- Decimal
- –
- Hex
- –
Converting decimal to binary is the classic exercise of every intro programming and networking course, and a practical need when you work with bit flags, subnet masks or register values. This converter shows the repeated division by 2 that produces the bits, and can pad the result to a fixed width of 8, 16, 32 or 64 bits. With a width chosen, it also shows negative numbers the way computers store them: in two’s complement.
How to use the decimal to binary converter
- Type the decimal number. Spaces and underscores are ignored, so
1_000_000works. - Leave Convert from set to decimal. You can switch to binary, octal or hex at any time.
- Optionally, pick a width under Pad the binary result to: 8, 16, 32 or 64 bits. The binary result is padded with leading zeros to that width.
- For a negative number, choose a width to see it in two’s complement at that width.
- Read the binary result, plus the octal and hex forms, and follow the division steps underneath. Use the copy button to copy any result.
How it works
Repeated division by 2
To turn a whole number into binary, divide it by 2 and keep the remainder, which is always 0 or 1. Divide the quotient by 2 again, and repeat until the quotient is 0. The remainders are the bits, from the lowest to the highest, so you read them from the bottom up.
Two’s complement for negative numbers
Most computers store signed integers in two’s complement at a fixed width. To get the pattern for −n:
- Write n in binary at the chosen width.
- Invert every bit (0 becomes 1, 1 becomes 0).
- Add 1.
The result is the same as 2^width − n. MDN’s JavaScript reference uses the same representation: its bitwise NOT example shows −3 as thirty 1 bits followed by 01 in 32 bits, and it notes that BigInt values are encoded as two’s complement. The leftmost bit acts as the sign: 1 means negative.
A number has to fit in the width you choose. In 8 bits, signed values run from −128 to 127 and unsigned values from 0 to 255; in 16 bits, from −32,768 to 32,767 and 0 to 65,535.
Worked examples
13 → 1101
| Division | Quotient | Remainder |
|---|---|---|
| 13 ÷ 2 | 6 | 1 |
| 6 ÷ 2 | 3 | 0 |
| 3 ÷ 2 | 1 | 1 |
| 1 ÷ 2 | 0 | 1 |
Reading the remainders from the bottom up gives 1101. Check: 8 + 4 + 1 = 13. Padded to 8 bits it is 00001101.
156 → 10011100
| 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 |
Bottom up: 10011100. Check: 128 + 16 + 8 + 4 = 156.
1000 → 1111101000
Ten divisions give the remainders 0, 0, 0, 1, 0, 1, 1, 1, 1, 1; read backward that’s 1111101000 (512 + 256 + 128 + 64 + 32 + 8 = 1,000). In hex it is 3E8.
−5 in 8 bits → 11111011
5 in 8 bits is 00000101. Invert every bit: 11111010. Add 1: 11111011. Check: 2⁸ − 5 = 251, and 11111011 is 251 read as unsigned. At 16 bits the same number is 1111111111111011.
−100 in 8 bits → 10011100
100 is 01100100; inverted, 10011011; plus 1, 10011100. That’s the same bit pattern as 156 above, because 256 − 100 = 156: whether those bits mean 156 or −100 depends on whether the program treats them as unsigned or signed.
Common values
| Decimal | Binary | Padded to 8 bits |
|---|---|---|
| 1 | 1 | 00000001 |
| 10 | 1010 | 00001010 |
| 127 | 1111111 | 01111111 |
| 255 | 11111111 | 11111111 |
| −1 | −1 | 11111111 (two’s complement) |
| −128 | −10000000 | 10000000 (two’s complement) |
Note that 255 and −1 share the same 8-bit pattern: as with 156 and −100, only the signed or unsigned reading tells them apart.
Related guides
- Going the other way? Use the binary to decimal converter, which adds up the powers of 2.
- Need hex instead? The hex to decimal converter shows the place values of base 16.
- Linux file permissions are three groups of three bits written in octal: the chmod calculator turns them into 755-style modes.
Frequently asked questions
How do you convert decimal to binary by hand?
Divide the number by 2 and write down the remainder (0 or 1). Keep dividing the quotient by 2 until it reaches 0, then read the remainders from the last one to the first. For 13 that gives 1101.
What is 255 in binary?
11111111, eight 1 bits. 255 is 2^8 − 1, the largest number one byte can hold.
How are negative numbers written in binary?
Computers usually use two's complement: write the positive number at a fixed width, invert every bit and add 1. In 8 bits, −5 is 11111011. Pick a width in the converter to see it.
Why do I have to choose a width for negative numbers?
Two's complement depends on the width: −1 is 11111111 in 8 bits but sixteen 1s in 16 bits. Without a width the converter shows the binary digits with a minus sign in front.
Can I convert decimal fractions like 0.1?
No. The converter handles whole numbers of any size, but not fractions.
Related guides

Free tool
Binary to Decimal Converter
Convert a binary number to decimal and see which powers of 2 add up to the result. Hex and octal are shown too.
Free calculator

Free tool
Hex to Decimal Converter
Convert a hexadecimal number to decimal and see the working digit by digit. Binary and octal are shown too, for numbers of any length.
Free calculator
Free Developer and PC Tools
Free formatters, decoders and converters for developers and PC users. Everything runs in your browser, and nothing you type is sent anywhere.
2 min read