
...
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 guideline "void NUM05-J. Avoid incorrect mixing of signed integers with bitwise operators" for more information.
Exceptions
EXP06-EX1EX0: Parentheses may be omitted from mathematical expressions that follow the algebraic precedence rules. For instance, consider the expression:
...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="c4cc4c3baac6e59a-a737d70e-42c34ec2-a82b9da7-af204bcc8b69f46d4dea068f"><ac:plain-text-body><![CDATA[ | [[ESA 2005 | AA. Bibliography#ESA 05]] | Rule 65: Use parentheses to explicitly indicate the order of execution of numerical operators | ]]></ac:plain-text-body></ac:structured-macro> | |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="b38658ebdce23b23-49df0a3d-41e9439b-9f2cb5ab-0494bacf5f761d28f0e00989"><ac:plain-text-body><![CDATA[ | [[Tutorials 2008 | AA. Bibliography#Tutorials 08]] | [Expressions, Statements, and Blocks | http://java.sun.com/docs/books/tutorial/java/nutsandbolts/expressions.html] | ]]></ac:plain-text-body></ac:structured-macro> |
| |||||
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="63b4fb93f0630987-b288dd16-44f94399-99b98aa1-55951bae1fbe513aec5cb895"><ac:plain-text-body><![CDATA[ | [[Rogue 2000 | AA. Bibliography#Rogue 2000]] | Rule 77: Clarify the order of operations with parentheses | ]]></ac:plain-text-body></ac:structured-macro> |
...