...
| Code Block | ||
|---|---|---|
| ||
public int do_operation(int a, int b) throws ArithmeticException {
if( (b>0 &&? (a > Integer.MAX_VALUE - b)) || (b<0 && (: a < Integer.MIN_VALUE - b)) ) {
throw new ArithmeticException();
}
return a + b; //Value within range can perform the addition
}
|
...
| Code Block | ||
|---|---|---|
| ||
public int do_operation(int a, int b) throws ArithmeticException {
if( (b>0 &&? (a < Integer.MIN_VALUE + b)) || (b<0 && (: a > Integer.MAX_VALUE + b)) ) {
throw new ArithmeticException();
}
return a - b; //Value within range can perform the addition
}
|
...