Decimal to binary conversion

Decimal to binary number converter and how to convert.

Decimal to binary converter

Enter a decimal number and press the Convert button:

10
   
Binary result: 2

Binary to Decimal conversion ►

How to convert decimal to binary

In order to convert decimal number x to binary number:

For decimal number x:

  1. Get the highest power of 2 that is less than the decimal number x:

    2n < x, (n=1,2,3,...)

  2. The high binary digit is equal 1:

    dn = 1

  3. Calculate the difference Δ of the number x and he power of 2, 2n:

    Δ = x - 2n

  4. Repeat step #1 with the difference until the result is 0.

Example

Convert x=13 to binary.

Solution

n=3, 23=8 < 13

n=4, 24=16 > 13

So

n = 3

d3 = 1

Δ = 13 - 23 = 5

n = 2, x = Δ = 5

d2 = 1

Δ = 5 - 22 = 1

n = 1, x = Δ = 1

d2 = 0

n = 0, x = Δ = 1

d0 = 1

Δ = 1 - 1 = 0

(d3d2d1d0)  = 1101

So 13 in decimal is equal to 1101 in binary:

x = 1310 = 11012

 


See also

Write how to improve this page