Firstly, you cannot shift byte in java, you can only shift int or long . Thus, byte will advance first, for example.
00101011 β 00000000000000000000000000101011
or
11010100 β 11111111111111111111111111010100
Now x >> N means (if you consider it as a string of binary digits):
- The rightmost N bits are discarded
- The leftmost bit is replicated as many times as necessary to fit the result in its original size (32 or 64 bits), for example.
00000000000000000000000000101011 >> 2 β 00000000000000000000000000001010
11111111111111111111111111010100 >> 2 β 11111111111111111111111111110101
finnw Jul 22 2018-10-22T00: 00Z
source share