Back to Error Prone

XorPower

docs/bugpattern/XorPower.md

2.49.0177 B
Original Source

The ^ binary XOR operator is sometimes mistaken for a power operator, but e.g. 2 ^ 2 evaluates to 0, not 4.

Consider expressing powers of 2 using a bit shift instead.