plain/devtools home

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.

number-basesampless sample

never leaves your browser

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: 1100100

Check: 64 + 32 + 4 = 100.

Examples

DecimalBinary
6110
101010
1001100100
25511111111

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) // 100

Running 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

Related

esc
↑↓ move↵ open? all shortcuts

Keyboard shortcuts

Cmd or Ctrl shortcuts always work.
Everywhere
Everywhere
Open the command palette
CtrlK
Open the palette (outside a text field)
/
Show these shortcuts
?
Toggle light and dark theme
t
Go home
gh
Go to all tools
gt
On a tool page
On a tool page
Run the main action
Ctrl↵
Copy the output
c
Load the next sample
s
Focus the input
i
Leave a text field
Esc
Previous or next tool
[]
In the palette
In the palette
Move the selection
↑↓
Open the selected item
↵
Close
Esc