# Decimal to Binary

A decimal-to-binary conversion is done to convert a decimal number (base 10) to its equivalent binary number (base 2). The methods used to convert a decimal number to its binary counterpart are discussed below.

## Dividing by 2

In this method, the given decimal number is divided recursively by 2 until we get 0 as the final quotient.

Let us convert the decimal number (167)10  to its binary.

On dividing 167 by 2, we get quotient = 83 and remainder = 1

Further, the quotient 83 is divided by 2, here, the quotient is 41, and the remainder is 1.

We repeat the above step till we get the quotient as 0.

41 Ã· 2, quotient = 20, and remainder = 1

20 Ã· 2, quotient = 10, and remainder = 0

10 Ã· 2, quotient = 5, and remainder = 0

5 Ã· 2, quotient = 2, and remainder = 1

2 Ã· 2, quotient = 1, and remainder = 0

1 Ã· 2, quotient = 0, and remainder = 1

When the quotient is 0, the binary number is obtained by writing the remainders in reverse order (from last to first).

Here, (167)10 = (10100111)2.

For Decimal Fractional Numbers

Here, we repeatedly divide the integral part of any decimal fraction by 2 until the quotient is 0, while the fractional part is repeatedly multiplied by 2 till we get 0 as the fractional part.

Let us consider the decimal number 15.6875 and transform it into a binary.

For the Integral Part

For the Fractional Part

On multiplying the fractional part of 15.6875 by 2, we get

0.6875 Ã— 2 = 1.375 = 0.375 + 1

Further, the fractional part of the result (0.375) is multiplied by 2

0.375 Ã— 2 = 0.75 = 0.75 + 0

We repeat the above step until the fractional part is 0.

0.75 Ã— 2 = 1.5 = 0.5 + 1

0.5 Ã— 2 = 1 = 0 + 1

When the fractional part is 0, the binary fractional part is obtained by writing the integrals from first to last. Here, the binary fractional part is 0.1011.

Thus, (15.6875)10 = (1111.1011)2

## Chart

The decimal numbers 0 to 20 and their equivalent binary numbers are in the following table:

## Alternative Method (By Descending Powers of 2)

Let us convert the decimal number 167 into a binary using this method.

First, we list the powers of 2 in a table, as shown.

Now, choosing the largest number that will fit into 167, we get 128.

Thus, we write 1 beneath 128 in the table as the leftmost digit of the binary.

Remaining value = 167 – 128 = 39.

Again, by choosing the number that will fit into 39, we get 32.

Thus, we write 0 beneath 64 and 1 beneath 32.

Remaining value = 39 – 32 = 7.

Similarly, by choosing the number, we get 4 that will fit into 7.

Thus, we write 0 beneath 16, 0 beneath 8, and 1 beneath 4.

Now, 7 – 4 = 3, which means 2 will fit into 3.

Thus, we write 1 beneath 2.

Now, 3 – 2 = 1, which means 1 in the table will fit into 1.

Thus, we finally write:

Here, we mark a 1 beneath each number that fits into the new value or a 0 beneath each that does not. The final result will be the same from left to right, based on the order of 1 and 0 in the table.

We get (167)10 = (10100111)2.

Convert (31)10 into a binary number.

Solution:

Find the binary number of the decimal 11.125.

Solution: