Wednesday, 30 January 2013

Shift Operator (signed/unsigned)

Shift operator should be used very carefully .Because a little change in shift operator makes a major change in output.So it is very necessary to understand how it is internally work.Today I run a program which explains about shift operator .We need to take many signed & unsigned int & char variables.Then assign them some value.After performing right shift operation we conclude that the value of an integer become half of the previous value if we right shift the value by 1.Thus as we right shift by different values our previous value become half of its previous value.If we right shift a char say B by 1 which has a ASCII value 66 then it converts   char which has a ASCII value 33.The Same theory is applied to conversely applied to the right shift which double the previous value if we right shift by 1.If we right shift by 4 then it doubles the value 4 times .So It very useful in various opearation.    

No comments:

Post a Comment