Decimal to binary
Divide the number by 2 repeatedly, write down each remainder, and read the remainders from last to first. 255 in binary is 11111111: eight ones, because 255 is 2^8 minus 1.
Last reviewed 2026-11-04.
Worked example: 100
Divide by 2 until you reach 0:
$ 100 / 2 = 50 remainder 0
50 / 2 = 25 remainder 0
25 / 2 = 12 remainder 1
12 / 2 = 6 remainder 0
6 / 2 = 3 remainder 0
3 / 2 = 1 remainder 1
1 / 2 = 0 remainder 1
Read the remainders bottom to top: 1100100Check: 64 + 32 + 4 = 100.
Examples
| Decimal | Binary |
|---|---|
| 6 | 110 |
| 10 | 1010 |
| 100 | 1100100 |
| 255 | 11111111 |
Fractions
For the part after the point, multiply by 2 and take the whole number each time. 0.625: 0.625 x 2 = 1.25 (1), 0.25 x 2 = 0.5 (0), 0.5 x 2 = 1.0 (1). So 0.625 is 0.101. Many decimals never terminate: 0.1 is 0.0001100110011... repeating, which is why 0.1 + 0.2 is not exactly 0.3 in floating point.
In code
$ (255).toString(2) // '11111111'
parseInt('1100100', 2) // 100Running this on a server
For bit masks and network work, see CIDR subnet sizes. Servers for small tools are compared in the hosting guide.
Frequently asked questions
What is 255 in binary?
11111111 (eight bits, all set).
How many bits does a number need?
The position of the highest set bit. 255 needs 8 bits; 256 is 100000000 and needs 9.
How do I convert negatives?
Computers use two's complement. The tool shows 8, 16, 32 and 64 bit forms.
Sources
- MDN: Number.prototype.toString() checked 2026-11-04
- MDN: parseInt() checked 2026-11-04