Skip to content
Sealpaste

Delete all recent work?

This removes the 0 items saved in this browser. Your settings stay.

Stop saving recent work?

New work won't be saved in this browser. The 0 items already saved can stay or go.

Decimal to Binary

Ready
Runs in your browser. Nothing you paste is uploaded unless you share it.

Convert decimal to binary, exact for big numbers, with the divide-by-two steps

Type a decimal number and read its bits grouped in fours, with the divide-by-two steps written out and negative numbers as two’s complement.

How to use it

  1. Type a whole number or a decimal fraction. Commas are fine: 1,000,000 reads as a million.
  2. Read its bits on top, grouped by four, and the division by 2 under it.
  3. For a negative number, pick the width in Bits to see the bits a computer stores.

Examples

A whole number

Input
156
Result
1001 1100

128 + 16 + 8 + 4 = 156

A negative number in 16 bits

Input
-5
Result
1111 1111 1111 1011

Bits: 16. Invert 0000 0000 0000 0101 and add 1.

How to convert decimal to binary by hand

Divide by 2 and write down the remainder, then divide the quotient again, until it reaches 0. The remainders read from the last one up are the binary number. For 13: 13 ÷ 2 = 6 remainder 1, 6 ÷ 2 = 3 remainder 0, 3 ÷ 2 = 1 remainder 1, 1 ÷ 2 = 0 remainder 1, so 13 is 1101.

Negative numbers: two’s complement

Write the positive number at the width you need, invert every bit, then add 1. The top bit then says the sign. A width holds -2ⁿ⁻¹ to 2ⁿ⁻¹ − 1: -128 to 127 in 8 bits, -32,768 to 32,767 in 16.

Decimal8 bitsHex
-11111 1111ff
-421101 0110d6
-1281000 000080
1270111 11117f

Questions

How do I convert a decimal fraction to binary?
Multiply the fraction by 2; the whole part (0 or 1) is the next bit, and you go on with what is after the point. 0.625 gives 1.25, 0.5, 1.0: 0.101. Some fractions never end, like 0.1, which repeats 0011 without end; the page shows that part in brackets.
How many bits does a number need?
As many as its binary digits: 255 needs 8, 256 needs 9. With Bits on Auto the page picks the smallest of 8, 16, 32, 64 and 128 that holds it, and says when it doesn’t fit the width you picked.
Can I type 5.72e2 or 1e-3?
Yes. On this page e-notation is read exactly: 5.72e2 is 572 and 1e-3 is 0.001, with exponents up to ±1000. On the number base converter in Auto, 1e3 is also a hex number (483), so it is read as hex and a line says what it would be as decimal.
Is the number I type uploaded?
No. Everything runs in your browser, so your numbers stay on your device. Nothing you paste is uploaded unless you share it.

Related tools