Monday, 23 April 2012

How to Convert from Decimal to Binary

The decimal number system has base 10 and binary number system has base 2. In study of computer science, we often need to convert a decimal number to a binary one. The following approach will teach how to convert a decimal number to a binary one.

The approach is simple. Take a decimal number 9 and now we will convert it to decimal.
Divide this number by 2 as it is the base of the binary numeral system. The remainder will always either be 0 or 1. Then keep this remainder and divide the quotient by 2. We will do this method until we reach the quotient as 0.

9 ÷ 2 = quotient 4 and remainder 1
4 ÷ 2 = quotient 2 and remainder 0
2 ÷ 2 = quotient 1 and remainder 0
1 ÷ 2 = quotient 0 and remainder 1  
Now start with the bottom remainder, read the sequence of remainders upwards to the top, we will get the binary number 1001. Here the last or bottom remainder is 1 as 1 ÷ 2 = quotient 0 and remainder 1 and top remainder is also 1 as 9 ÷ 2 = quotient 4 and remainder 1.

Take another decimal number 47 and its binary value is 101111. We will find it out now.
47 ÷ 2 =  quotient 23 and remainder  1
23 ÷ 2 =  quotient 11 and remainder  1 
11 ÷ 2 =  quotient 5 and remainder    1
5 ÷ 2  =  quotient 2 and remainder     1
2 ÷ 2  =  quotient 1 and remainder     0
1 ÷ 2 =   quotient 0 and remainder     1  
If start with the bottom remainder, read the sequence of remainders upwards to the top, we will get the binary number 101111.

Above we  have discussed about converting integer decimal into binary. What will we do in case of fractional number?  Suppose the number is .25 and how can we convert it into binary. We will do it in the following way:
First, we will multiply the fractional part by 2 and then keep the whole number part or the result. We will continue this approach until we reach to a full integer. So,
0.25  × 2 = 0.50  keep  0  (Here 0 is whole number part and .50 is fractional part)
0.50  × 2 = 1.0    keep  1  (Here 1 is whole number part and .0 is fractional part)
Now we will count it from top to bottom and we will get 01 as 0 is the top digit and 1 is the last digit.

So the binary of .25 is  0.01

Take another number  0.5625 and find its binary value.

0.5625  × 2 = 1.125  keep  1  (Here 1 is whole number part and .125 is fractional part)
0.125    × 2 = 0.25    keep  0
0.25      × 2 = 0.50    keep  0 
0.50      × 2 = 1.0      keep  1  

Start count from top to bottom  the binary number will be 0.1001


No comments:

Post a Comment

What Is The Difference Beween Numerals and Number?

Number is a concept, it is a mathematical concept. To express the quantitative value of the object, this  is developed in ancient history. S...