I have a long which is made with this code:
long binary = 0b1L<< 63;
This gives the expected result, a one at the 63rd index:
1000000000000000000000000000000000000000000000000000000000000000
But when I take this long, and apply the >> operator to it, it gives me an unexpected result. For example, when I call this code snippet on the above binary:
long newBinary = binary >>8;
It shifts right the right amount, but it fills the leading zeros with ones:
1111111110000000000000000000000000000000000000000000000000000000
Is there a specific reason why this is happening?