Decimal to binary
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 1 | 1 | 1 | 1 |
| 8 | 1000 | 10 | 8 |
| 10 | 1010 | 12 | A |
| 15 | 1111 | 17 | F |
| 16 | 10000 | 20 | 10 |
| 64 | 1000000 | 100 | 40 |
| 100 | 1100100 | 144 | 64 |
| 255 | 11111111 | 377 | FF |
| 256 | 100000000 | 400 | 100 |
| 1024 | 10000000000 | 2000 | 400 |
| 65535 | 1111111111111111 | 177777 | FFFF |
Divide repeatedly by two and read the remainders backwards. 170 gives 10101010. Alternatively subtract the largest power of two that fits and repeat: 170 − 128 − 32 − 8 − 2 = 0.
How to convert decimal to binary
The subtraction method is faster by hand than repeated division. Write down the powers of two above your number, then work down: does 128 fit in 200? Yes, so write 1 and subtract, leaving 72. Does 64 fit in 72? Yes, leaving 8. Does 32 fit in 8? No, write 0 — and so on down to 11001000. It produces the digits left to right in one pass rather than in reverse.
A few shapes are worth recognising rather than converting. Every power of two is a single 1 followed by zeros, so 1024 is a 1 and ten zeros. Every number one below a power of two is a solid run of ones, so 255 is eight of them. And the last digit alone tells you odd or even, because it is the only place worth 1.
The decimal point is refused rather than truncated, and that is deliberate. Binary fractions exist. The places after the point are halves, quarters, eighths, but most decimal fractions have no exact binary form. 0.1 repeats forever in binary, which is the whole reason 0.1 + 0.2 does not give exactly 0.3 in floating-point arithmetic. Silently dropping the fraction would hand back an answer that looks right and is not.
Questions
1010.
Subtract the largest power of two that fits, repeat, and write 1 or 0 for each power in turn.
Ten, since 2^10 is 1024 and 2^9 is only 512.
It is a single 1 followed by zeros. A number one below a power of two is the opposite. All ones, like 255.
Because a long binary run is unreadable. Groups of four map to one hex digit each.
The notation can, but this tool refuses one rather than truncating it. Most decimal fractions do not terminate in binary; 0.1 repeats forever, which is why floating-point arithmetic surprises people.
Yes. The final bit is the ones place, so a number is odd exactly when it ends in 1.