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;
}
This rule doesn't raise an issue when the shift by zero is obviously for cosmetic reasons:
bytes[loc+0] = (byte)(value >> 8); bytes[loc+1] = (byte)(value >> 0);