Wednesday, September 16, 2015

Shift Operator Tutorials in C

SHIFT OPERATION IN C 


I had more times learned the bit shift operator after some days i am forgetting that . so i am expressing the details how it works . through this i can rewind this post to learn it ..



Left shift operator 
 The syntax for writing shift operator as follows

[variable]<<[number of places]

This is writing as follows
                     1<

Here 1 is  variable ,the operator << ; left shift  and a is the number ie, how much bit position is needed to shift to left.

 In detail :
    In the LEFT shift (<<)   first you write an N number of  of zeros , where the 'N" is the number placed in number of places

 for Example :  
             1)          1<<3 font="">
                       ie ,    1 will be left shift by putting 3 zeros 

                      ie, 1 wrote first and put 3 zeros 

                     1000 

                     finally

                  1<<3 1000="" 16="" binary="" decimal="" font="" in="" or="">

Example 2)
                         3>>3;
                          11... then 3 zeros
                          11000 = 24 in decimal

Example 3)
                        5<<3 comment-3--="">

                       101... 000

                     ie 101000


Example 3)   3<<5 comment-5--="">

                     1100000


***********************************************************************************



No comments:

Post a Comment