Mixed types in expressions
ID | STAT-7 |
Title | Do not use multiple operand types per operator. |
Priority | Mandatory |
Severity level | 3 |
Description | Do not use multiple operand types per operator. For example, do not mix logical and numerical operands with a multiplication operator. |
Rationale | Mixing operand types per operator can cause unexpected results and may lead to errors in case of true incompatibilities. |
Avoid:
d = a * b && c;
Instead use:
d = (a * b > 0) && c;