...
Code Block | ||
---|---|---|
| ||
public static final int MASK = 1337; public static final int OFFSET = -1337; public static int computeCode(int x) { return (x & MASK) + OFFSET; } |
Note that this solution performs bitwise operations on signed integers. Care must be exercised when doing this; see INT06-J. Avoid incorrect mixing of signed integers with bitwise operators for more information.
Exceptions
EXP00-EX1: Parentheses may be omitted from mathematical expressions that follow conventional algebraic order. For instance, consider the expression:
...