Decimal to Binary Converter
Type a decimal number and see its binary form, grouped into nibbles if you like, as you type.
Convert Decimal to Binary Online
Setting a bit mask, reading a subnet, packing flags into a byte or checking homework all start with the same question: what is this number in binary? This page is the Number Base Converter with decimal selected as the input base.
The division method
Divide by 2, note the remainder, and keep dividing the quotient until it reaches 0. The binary number is the remainders read from bottom to top. For 42:
| Step | Division | Remainder |
|---|---|---|
| 1 | 42 ÷ 2 = 21 | 0 |
| 2 | 21 ÷ 2 = 10 | 1 |
| 3 | 10 ÷ 2 = 5 | 0 |
| 4 | 5 ÷ 2 = 2 | 1 |
| 5 | 2 ÷ 2 = 1 | 0 |
| 6 | 1 ÷ 2 = 0 | 1 |
Reading the remainders upwards gives 101010.
Two's complement for negative numbers
Computers store negative integers in two's complement: invert every bit of the positive value and add one. The converter does this for you at the smallest standard width. -1 is all ones, 11111111 in 8 bits, and -129 no longer fits in 8 bits, so it is shown in 16 bits as 1111111101111111.
A shortcut with powers of two
For small numbers it is often faster to subtract powers of two. Take the largest power of two that fits, write a 1 for it, subtract, and continue down to 1, writing 0 for every power that does not fit. 42 contains 32 (leaving 10), not 16, then 8 (leaving 2), not 4, then 2, not 1: 1, 0, 1, 0, 1, 0, which is 101010 again.
Related conversions
To read binary back as decimal, use binary to decimal. To see how letters are stored as bits, text to binary converts text byte by byte.