the shift operators..
1. >> signed right shift : the left most bit is inserted.
2. << signed left shift : 0 is inserted from the right
3. >>> unsigned right shift: 0 is inserted from the left
now u need to understand how we represent a decimal no. in binary. we know a int is 32 bitsa in
java. so there will be 32
bits in any decimal no.
say 18 : 0000 0000 0000 0000 0000 0000 0001 0010
now i hope u understand how i represented the no. 18 in binary..
u also need to understand what is meant by signed and unsigned shift..
the left most bit is meant for sign and if it is 1 the no. is negative.
if the bit is 0 the no is positive.
now what i mean by signed shift is that the sign of the no. will be maintained.
i.e no matter how many times u shift right with << or >> the sign will be preserved.
>>> instead inserts a 0 on the left ..so if there is a 1 on the left most bit, the no. is negative, once u insert the 0 , the no changes sign from -ve to +ve.
one imp thing.
a>>32 will not shift the no at all why? because the right hand side is divided by 32 and the no is shifted by the remainder.thus the shift is actually
a>>b%32 in real sense.