C programmers commonly make errors regarding the precedence rules of C operators due to the nonintuitively low precedence levels of "&", "|", "^", "<<", and ">>". Mistakes regarding precedence rules can be avoided by the suitable use of parentheses. Using parentheses defensively reduces errors and, if not taken to excess, makes the code more readable.
Non-Compliant Code Example
...
To get this code to behave as expected, parentheses should be used to specify the order of operation.Mistakes regarding precedence rules can be avoided by the suitable use of parentheses. Using parentheses defensively reduces errors and, if not taken to excess, makes the code more readable.
Code Block | ||
---|---|---|
| ||
(x & 1) == 0 |
...