Since an int
is a 32-bit variable, shifting by more than +/-31 is confusing at best and an error at worst. Shifting an
int
by 32 is the same as shifting it by 0, and shifting it by 33 is the same as shifting it by 1.
Similarly, shifting a long
by +/-64 is the same as shifting it by 0, and shifting it by 65 is the same as shifting it by 1.
public int shift(int a) { return a << 48; }
public int shift(int a) { return a << 16; }