Decimal to binary
Turn decimal numbers into binary, padded to 8, 16, 32 or 64 bits when you want.
Result
Settings
Result
Settings
Result
Settings
Result
Recent
To turn a decimal number into binary, divide by 2 until you reach 0 and read the remainders backwards. Type 13 or 1000 and the bits appear immediately, spaced in fours or eights if you like, with the same value in hex and octal. It costs nothing and asks for no login.
How to do it by hand
- Divide the number by 2. The remainder is either 0 or 1.
- Divide the quotient by 2 again and write down the new remainder.
- Stop once the quotient is 0.
- Read the remainders from the bottom up to get the bits.
- Another route: subtract the largest power of 2 that fits, put a 1 in that place, and repeat with what is left.
Worked examples
13
13 → 6 r 1, 6 → 3 r 0, 3 → 1 r 1, 1 → 0 r 1
1101
100
64 + 32 + 4
1100100
1000
512 + 256 + 128 + 64 + 32 + 8
1111101000
Common mistakes
- Reading the remainders top to bottom, which writes the bits backwards.
- Expecting eight digits for small numbers. 5 is just 101; turn on zero padding to see 00000101.
- Writing negatives with a minus sign when the data is a byte. In 8 bits, -5 is stored as 11111011.
Binary for 0 to 20
| Decimal | Binary | Bits needed |
|---|---|---|
| 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 |
Questions people ask
How many bits does a number need?
Find the smallest power of 2 above it. 1000 is below 1024, which is 2 to the 10th, so it fits in 10 bits.
Can I convert a whole list at once?
Yes. Put one number per line, or split them with commas or spaces, and each one gets its own row.
Why does 0.1 never end in binary?
0.1 is 1/10, and the factor 5 in 10 cannot be built from powers of 2. The fraction mode writes it as 0.0(0011), where the part in brackets repeats.