- Related Questions & Answers
- How to Convert Binary to Decimal?
- How to convert Decimal to Binary in JavaScript?
- How to convert Binary to Decimal in JavaScript?
- How to convert Decimal to Binary using C#?
- Convert Decimal to Binary in Java
- C# Program to Convert Binary to Decimal
- C# Program to Convert Decimal to Binary
- C++ Program To Convert Decimal Number to Binary
- Java Program to convert from decimal to binary
- Python program to convert decimal to binary number
- How to Convert Decimal to Binary Using Recursion in Python?
- Java program to convert decimal number to binary value
- Java program to convert binary number to decimal value
- Java Program to convert binary number to decimal number
- Convert decimal to binary number in Python program

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

**Decimal** number is most familiar number system to the general public. It is base 10 which has only 10 symbols − 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9. Whereas **Binary** number is most familiar number system to the digital systems, networking, and computer professionals. It is base 2 which has only 2 symbols: 0 and 1, these digits can be represented by off and on respectively.

There are various direct or indirect methods to convert a decimal number into binary number. In an indirect method, you need to convert a decimal number into other number system (e.g., octal or hexadecimal), then you can convert into binary number by converting each digit into binary number.

**Example** − Convert decimal number 125 into binary number.

First convert it into octal or hexadecimal number, = (125)_{10}= (1x8^{2}+7x8^{1}+5x8^{0})_{10}or(7x16^{1}+13x16^{0})_{10}Because base of octal and hexadecimal are 8 and 16 respectively. = (175)_{8}or(7D)_{16}Then convert it into binary number by converting each digit. = (001 111 101)_{2}or(0111 1101)_{2}= (01111101)_{2}

However, there are two direct methods are available for converting a decimal number into binary number: Performing Short Division by Two with Remainder (for integer part), Performing Short Multiplication by Two with result (For fractional part) and Descending Powers of Two and Subtraction. These are explained as following below.

This is a straightforward method which involve dividing the number to be converted. Let decimal number is N then divide this number from 2 because base of binary number system is 2. Note down the value of remainder, which will be either 0 or 1. Again divide remaining decimal number till it became 0 and note every remainder of every step. Then write remainders from bottom to up (or in reverse order), which will be equivalent binary number of given decimal number. This is procedure for converting an **integer decimal** number, algorithm is given below.

Take decimal number as dividend.

Divide this number by 2 (2 is base of binary so divisor here).

Store the remainder in an array (it will be either 0 or 1 because of divisor 2).

Repeat the above two steps until the number is greater than zero.

Print the array in reverse order (which will be equivalent binary number of given decimal number).

Note that dividend (here given decimal number) is the number being divided, the divisor (here base of binary, i.e., 2) in the number by which the dividend is divided, and quotient (remaining divided decimal number) is the result of the division.

**Example** − Convert decimal number 112 into binary number.

Since given number is decimal integer number, so by using above algorithm performing short division by 2 with remainder.

Division | Remainder (R) |
---|---|

112 / 2 = 56 | 0 |

56 / 2 = 28 | 0 |

28 / 2 = 14 | 0 |

14 / 2 = 7 | 0 |

7 / 2 = 3 | 1 |

3 / 2 = 1 | 1 |

1 / 2 = 0 | 1 |

Now, write remainder from bottom to up (in reverse order), this will be 1110000 which is equivalent binary number of decimal integer 112.

But above method can not convert fraction part of a mixed (a number with integer and fraction part) decimal number. For **decimal fractional** part, the method is explained as following below.

Let decimal fractional part is M then multiply this number from 2 because base of binary number system is 2. Note down the value of integer part, which will be either 0 or 1. Again multiply remaining decimal fractional number till it became 0 and note every integer part of result of every step. Then write noted results of integer part, which will be equivalent fraction binary number of given decimal number. This is procedure for converting an **fractional decimal** number, algorithm is given below.

Take decimal number as multiplicand.

Multiple this number by 2 (2 is base of binary so multiplier here).

Store the value of integer part of result in an array (it will be either 0 or 1 because of multiplier 2).

Repeat the above two steps until the number became zero.

Print the array (which will be equivalent fractional binary number of given decimal fractional number).

Note that a multiplicand (here decimal fractional number) is that to be multiplied by multiplier (here base of 2, i.e., 2)

**Example** − Convert decimal fractional number 0.8125 into binary number.

Since given number is decimal fractional number, so by using above algorithm performing short multiplication by 2 with integer part.

Multiplication | Resultant integer part (R) |
---|---|

0.81252 x 2= 1.625 | 1 |

0.6252 x 2= 1.25 | 1 |

0.252 x 2= 0.50 | 0 |

0.52 x 2= 1.0 | 1 |

0 x 2 = 0 | 0 |

Now, write these resultant integer part, this will be 0.11010 which is equivalent binary fractional number of decimal fractional 0.8125.

This method is gussing binary number of a decimal number. You need to draw a table of power of 2, then take given decimal number and subtract it from maximum possible power of 2 that does not return resultant number negative. Then put 1 into that box of this power in the table. Repeat these steps till number is greater than zero. Put a 0 in all other empty boxes and take the output which will be equivalent binary number of given decimal number. For **integer part**, The algorithm is explained as following below.

Start by making a chart.

Look for the greatest power of 2.

Move to the next lower power of two.

Subtract each successive number that can fit, and mark it with a 1.

Continue until you reach the end of your chart.

Write out the binary answer.

**Example** − Convert decimal number 205 into binary number.

Take table of power of 2,

Decimal | 2^{7} = 128 | 2^{6} = 64 | 2^{5} = 32 | 2^{4} = 16 | 2^{3} = 8 | 2^{2} = 4 | 2^{1} = 2 | 2^{0} = 1 |

Binary | 1 | 1 | 0 | 0 | 1 | 1 | 0 | 1 |

Subtract given number 205 from maximum possible power of 2, = 205 - 128 = 77 Put 1 in box of 128 (= 27), then again subtract remaining number 77 from maximum possible power of 2, = 77 - 64 =13 Put 1 in box of 64 (= 2^{6}), then repeat above steps, = 13 - 8 =5 = 5 - 4 =1 = 1 - 1 =0 And put a 0 in remaining boxes. Therefore equivalent binary number will be 11001101 of given 205 decimal number.

Advertisements