Decimal to Binary Converter

Type a decimal number and this decimal to binary converter writes it in base 2 straight away. It also shows octal and hex, and turns negative numbers into 8, 16, 32, or 64-bit two's complement.

Updated
Runs in your browser. Your data is not uploaded.

Whole numbers of any length. Fractions (0.1) and a minus sign work too. Prefixes such as 0x, 0b, and 0o are accepted.

Result
–
Binary (base 2)
–
Octal (base 8)
–
Decimal (base 10)
–
Hexadecimal (base 16)
–

How to use the Decimal to Binary Converter

  1. Type a decimal Number, such as 156.
  2. The binary result appears at once, grouped in fours so it is easy to read.
  3. For a negative number, pick a width under Two's complement. Press the swap button to convert binary back to decimal.

How it works

Divide the number by 2 and write down the remainder. Repeat with the quotient until it reaches 0. The remainders read from bottom to top are the binary digits.

156 ÷ 2 = 78 remainder 0
 78 ÷ 2 = 39 remainder 0
 39 ÷ 2 = 19 remainder 1
 19 ÷ 2 =  9 remainder 1
  9 ÷ 2 =  4 remainder 1
  4 ÷ 2 =  2 remainder 0
  2 ÷ 2 =  1 remainder 0
  1 ÷ 2 =  0 remainder 1
156 = 10011100

To check, add the place values of the 1 bits: 128 + 16 + 8 + 4 = 156.

Examples

  • 156 = 10011100.
  • 10 = 1010.
  • 255 = 11111111, the largest 8-bit value.
  • 0.5 = 0.1, and 0.1 = 0.0(0011), which never ends.

Decimal to binary table

DecimalBinary8-bit
0000000000
1100000001
21000000010
31100000011
410000000100
510100000101
8100000001000
10101000001010
161000000010000
201010000010100
3210000000100000
5011001000110010
64100000001000000
100110010001100100
1281000000010000000
2551111111111111111

Why 0.1 has no exact binary form

Only fractions whose denominator is a power of 2 end in binary: 0.5, 0.25, 0.375. A tenth is 1/10, and 10 has a factor of 5, so its binary digits repeat forever. This is why 0.1 + 0.2 isn't exactly 0.3 in most programming languages: the computer stores the nearest binary value.

Limitations

  • Fractions are shown to 20 binary digits.
  • Two's complement needs a whole number that fits the chosen width (−128 to 255 for 8 bits).

Frequently asked questions

How do I convert decimal to binary by hand?

Divide by 2, note the remainder, and repeat with the quotient until you reach 0. Read the remainders from last to first.

What is 100 in binary?

1100100.

How do I convert binary back to decimal?

Press the swap button, or add up the place values (1, 2, 4, 8, 16, ...) of every 1 bit.

How are negative numbers written in binary?

Usually in two's complement. Pick a width such as 8 bits, and −5 becomes 11111011.

Often used together with the Decimal to Binary Converter.