>> means right shift
>>> means unsigned right shift
>> when right shift the digits being inserted is most significant bit.
For example , let us take number 7 and -7.
1. 7 in binary is 0000 0111 . Other zeros are removed for clarity.
Now say 7 >> 2 . Since Most Signigicant Bit ( MSB) is 0 here so result came as 0000 0001.
Convert this number to decimal , and that is 1.
So 7 >> 2 is 1 in decimal.
Now take -7 >> 2.
Steps
step 1.
Convert 7 to binary.
that is 0000 0111.
step 2.
Then get 1's complement = 1111 1000 (just flip the digits)
b. add 1 to this number+ 1
------------
we got = 1111 1001
------------
Now shift it right 2 places.
Since we have MSB as 1 so 1 will be inserted into this
pattern.
Result wil be 1111 1111
So -7 >> 2 came up as 1111 1111.
But how to read this patteren.
Follow the same approach .
That is ( 1111 1111) = Negative(1111 1111) * -1
So lets find out negative of 1111 1111 and substitute in above equation.
step 1 . Flip all digits --- > 0000 0000
step 2 . Add 1 --- > + 1
-----------
Result 0000 0001
-----------
The decimal of 0000 0001 is 1.
Now put thjis value in the equation
( 1111 1111) = Negative(1111 1111) * -1
( 1111 1111) = 1 * -1
( 1111 1111) = -1
Thus the result"
-7 >> 2 = -1.
If it is -7 >>> 2 Then instead of inserting 1 we insert zeros so the result would be
-7 binary is 1111 1001.
Shift two places right inserting 0's so we got
0011 1110.
convert this to decimal we got
62.
Hope this clears your confusion.
Sorry I am not good at explaining. If it heps you then good.