...
The intent of the expression in this noncompliant code example is to test the least significant bit of x
.
Because of operator precedence rules, the expression is parsed as
which evaluates to
and then to 0
.
Compliant Solution
In this compliant solution, parentheses are used to ensure the expression evaluates as expected.
Exceptions
EXP00-EX1: Mathematical expressions that follow algebraic order do not require parentheses. For instance, in the expression
the multiplication is performed before the addition by mathematical convention. Consequently, parentheses to enforce this would be redundant.
Risk Assessment
...