Sunday 20 November 2016

             Binary to ASCII Code Conversion

  • A Binary number is a number system with only  two digits that is :  0's and 1's . 
  • These type of numbers having the base 2 .
For Example :


                                         
                                                                        Table 1


ASCII stands for American Standard Code for Information Interchange.Computers can only understand binary  numbers, so an ASCII code is the numerical representation of a character such as 'a' or '@' or an action of some sort.

Characters represented in a ASCII Code:

  • The basic ASCII set uses 7 bits for each character, giving it a total of 128 unique symbols. 
  • The extended ASCII character set uses 8 bits, which gives it an additional 128 characters
  • The extra characters represent characters from foreign languages and special symbols for drawing pictures.
ASCII Chart:
Table 2





Steps to Convert Binary Number to ASCII Number

1. Convert  every four Binary Digits to Hexadecimal Numbers


                                                                            Table 3


Example:  0100101101010000
                       
                           0100  1011  0101  0000
                               4        B         5         0
                               

2. Split the string of Hexadecimal digits into set of 2 digits
  •  When we are converting number into ASCII then every two hexadecimal digits makes a  Character.
  •  If your Hexadecimal string contains more than two digits than split the digits in the  pair of two hex digits 
  •  If in a string you have even numbers of digits then there is no need to add 0 in front of  the string. 


       In the above example we already have 2 hexadecimal digits i.e. 

         4 B   5 0


3. Now , in this step convert this hexadecimal digits to Decimal number

  •  For converting hex digits to decimal digits then simply multiply each digit with 16 and  then add second digit with that digit and so on. 
  • The number which you are multiplying that number should be in decimal form if that number is in hexadecimal character then write its decimal equivalent then multiply it.  
  • The number 16 which you are multiplying having the power 0 from the Right side of the first digit  and power increases  as we go on multiplying digits from Right to left


     4 =  Remains 4 
     B = From table 3 , we write 11 because in hexadecimal (B = 11)
     5 = Remains 5
     0 = Remains 0
     now , multiply these numbers with 16 and add them
   
      4*16^1 + 11*16^0 =>  75        5*16^1 + 0*16^0  => 80


4. After converting Hex digit into decimal number convert this number into ASCII code

  ( See table 2 , in that table your UPPERCASE letters starts from 65 and LOWERCASE               letters from 97 )

What to do now?

We know that uppercase letters starts from (65 = A) to (90 = Z)
And , lowercase letters starts from (97= a) to (122 = z)

so , the above example we have decimal digits as
75 = K 
80 = P 


RESULT = Binary :  0100101101010000  converted to ASCII : KP
       









No comments:

Post a Comment