...
Addition (and all operations) in Java are performed in signed numbers as Java does not support unsigned numbers
Noncompliant Code Example
Compliant Solution (Bounds Checking)
...
This noncompliant code example, can result in a signed integer overflow during the multiplication of the signed operands a and b. If this behaviour is unanticipated, the resulting value may lead to undefined behaviour
Noncompliant Code Example
Code Block | ||
---|---|---|
| ||
int a,b,result //do stuff result = a*b;//May result in overflow |
...
A non-compliant example is:
Noncompliant Code Example
Code Block | ||
---|---|---|
| ||
int a,b,result result = a/b; |
...