org.sonar.l10n.java.rules.squid.S2183.html Maven / Gradle / Ivy
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.
Noncompliant Code Example
public int shift(int a) {
return a << 48;
}
Compliant Solution
public int shift(int a) {
return a << 16;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy