Convert decimal to binary
Convert any whole number to binary, hex and octal with the repeated-division working shown step by step, and two’s complement for negatives.
- Runs in your browser
- Nothing you enter is sent
- Free, no account
Whole numbers only. Spaces, commas and underscores are ignored.
Enter a value above. Binary, decimal, hexadecimal, octal and the full working appear here.
The method, shown for your number
Divide by two, write down the remainder, divide the quotient by two, and repeat until the quotient reaches zero. Reading the remainders from the bottom upwards gives the binary representation. The table above does exactly that for whatever you type, row by row — the working, not just the answer.
Convert 13:
13 ÷ 2 = 6 remainder 1
6 ÷ 2 = 3 remainder 0
3 ÷ 2 = 1 remainder 1
1 ÷ 2 = 0 remainder 1
Read upwards: 1101 The subtraction method
Some people find this quicker. Write the powers of two down to your number, then take away the largest that fits, repeatedly:
Convert 200, using 128 64 32 16 8 4 2 1:
200 − 128 = 72 → 1 in the 128 column
72 − 64 = 8 → 1 in the 64 column
8 − 8 = 0 → 1 in the 8 column
Result: 11001000 Numbers worth knowing by sight
| Decimal | Binary | Hex | Where you meet it |
|---|---|---|---|
| 15 | 1111 | F | One hex digit, four bits |
| 16 | 10000 | 10 | Where hex carries |
| 127 | 1111111 | 7F | Largest signed 8-bit value; end of ASCII |
| 128 | 10000000 | 80 | The high bit alone |
| 255 | 11111111 | FF | Largest byte; an IP octet maximum |
| 1024 | 10000000000 | 400 | One kibibyte |
| 65535 | 16 ones | FFFF | Largest 16-bit value; the highest port number |
The pattern to internalise: n ones equals 2ⁿ − 1, and a single 1 followed by n zeros equals 2ⁿ. Almost every “why does it stop there?” limit in computing is one of those two.
Negative numbers and two's complement
Hardware does not store a minus sign. It stores the two's complement: invert every bit of the positive value and add one. Enter a negative number above and the panel shows the exact bit pattern at 8, 16, 32 or 64 bits.
−5 in 8 bits:
5 = 00000101
inverted = 11111010
add 1 = 11111011 (251 if read as unsigned) The elegance is that ordinary binary addition then works unchanged for negative numbers. The cost is an asymmetric range — an 8-bit signed value runs from −128 to +127, not −127 to +127, and the most negative value has no positive counterpart.
Very large numbers
All arithmetic here uses BigInt, so a 200-digit input converts exactly. JavaScript's ordinary numbers lose precision above 2⁵³ — about 9 quadrillion — which is why many online converters quietly return the wrong digits for large values. Paste something enormous and check the round-trip on the binary-to-decimal page.
What about fractions?
This page handles integers. Fractional binary is a different topic and a more interesting one:
0.1 in decimal has no finite binary representation, in the same way 1/3 has no finite decimal
one. That single fact explains why 0.1 + 0.2 is not 0.3 in almost
every programming language.
Questions
How does the repeated-division method work?
Divide the number by two, note the remainder, then divide the quotient by two and repeat until you reach zero. Reading the remainders bottom to top gives the binary digits. The full table is shown for your number.
How are negative numbers represented?
As two’s complement, which is what real hardware uses: take the positive value, invert every bit and add one. The tool shows the result at 8, 16, 32 or 64 bits, and warns when the value does not fit.
Can it handle very large numbers?
Yes. All arithmetic uses BigInt, so a 200-digit number converts exactly. JavaScript’s ordinary numbers would lose precision beyond about 9 quadrillion.
What about decimals like 12.5?
Not here. Fractional binary is a different problem — 0.1 has no finite binary representation at all, which is the root of most floating-point surprises. This page handles integers.