Sunday, June 9, 2013

Program to convert binary number system to decimal number system

How to convert binary to decimal:

To convert any binary number to decimal follow these steps:
1. Take the LSB(Least Significant Bit) and multiply it with 20.
2. Now take next bit and multiply it with 21.
3. Now take next bit and multiply it with 22.
4. Follow this multiplication of next bit and increasing power of 2 until we reach MSB(Most Significant Bit).
5. Now add all the results of the steps above.

We will have the decimal equivalent.

Example:
Here I am converting binary number 1010 to its decimal equivalent.
(1010)2=(?)10

1.     0*20=0
2.     1*21=2
3.     0*22=0
4.     1*23=8
5.     0+2+0+8=10
so binary equivalent of 1010 is 10.

(1010)2=(10)10

This program will calculate binary to decimal for you:

0 comments:

Post a Comment

Powered by Blogger.