[Solved] What does this mean (>> in calculation)? [duplicate]


Throughout this post let’s assume numbers are one hex digit, just for simplicity.

“>>” is the bit shift operator. For example:

8 >> 1 == 8 / 2 == 4;

Which in binary is equivalent to

b1000 >> 1 == b0100;

Adding the third “>” into the operator inserts a 0 into the now far left slot, instead of doing sign extension to determine it’s value.

-1 >> 1 = b1111
-1 >>> 1 = b0111

This is more useful for things like bit masks, where forcing the new value to 0 is convenient. And is only applicable to right shifting, there is no <<< operator.

0

solved What does this mean (<< and >>> in calculation)? [duplicate]