Monday 5 August 2013

Easily Convert from Different Number Systems to Decimal

In the world of computers we can use many Number Systems-- the most popular being binary, decimal, octal and hexadecimal. In this tutorial I will teach you how to manually convert from binary and hexadecimal systems to decimal. You will not need any calculator to do this because it is an easy process.


Binary to Decimal

Binary is the number system used by our computers internally. They don't understand our human languages. We need to tell them, for example - a is 1001010, b is 110010, etc. (this is just example and a is not 1001010!). Basically binary number system means two numbers: 1 and 0. Any numbers created using these two digits are called binary numbers.

Let us see a simple diagram that explains the arithmetic to convert binary digits to a decimal number that we understand.

Bits 7 6 5 4 3 2 1 0
     1 0 1 1 0 1 1 1
     + + + + + + + +--> 2^0 x bit 0 =>   1*1 =   1
     | | | | | | +----> 2^1 x bit 1 =>   2*1 =   2
     | | | | | +------> 2^2 x bit 2 =>   4*1 =   4
     | | | | +--------> 2^3 x bit 3 =>   8*0 =   0
     | | | +----------> 2^4 x bit 4 =>  16*1 =  16
     | | +------------> 2^5 x bit 5 =>  32*1 =  32
     | +--------------> 2^6 x bit 6 =>  64*0 =   0
     +----------------> 2^7 x bit 7 => 128*1 = 128
                                               183 (Decimal)

The binary number we use here is 10110111. Here the trick is to simply multiply the n powers to 2 with the binary number (that is 1 or 0 whatever is at the bit location). The numbers in italic above beside the "Bits" is the ordinal of the bits (0 or 1) as placed in the binary number-- backwards. Simply multiply as shown and add the numbers to get the decimal number equivalent of the binary number.


Hexadecimal to Decimal

The hexadecimal is the most popular number system in the world of computing after decimal (octal was replaced by hexadecimal as the most popular number system a long time back). The digits used are 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F. The digits A to F signify the numbers 10 through 15 respectively.


Digits 3 2 1 0
       4 6 8 9
       + + + +---> 16^0 x digit 0 =>    1*9 =     9
       | | +-----> 16^1 x digit 1 =>   16*8 =   128
       | +-------> 16^2 x digit 2 =>  256*6 =  1536
       +---------> 16^3 x digit 3 => 4096*4 = 16384
                                              18057 (Decimal)


The hexadecimal number we take here is 4689. The trick is similar as in the case of binary to decimal conversion. This time we use n powers to 16 (hexadecimal means 16).

In both the conversions above the maroon numbers are like constants that you can easily memorize. Especially in the case of binary multiplication is so simple-- just with a 1 or 0! How easy can it get? You won't need a calculator to do such conversions anymore ;)

Hope you liked this small tutorial. If you did plz share with your friends too! Till then goodbye :)



0 comments:

Post a Comment

All Articles © Asit. No Copying. Powered by Blogger.
 
Copyright © . The Tech Veda - Posts · Comments
Markup Powered by Bluefish Editor 2.2