...
Although we can not have undefined behaviour in Java we still have to ensure that we get the correct results. So we should explicitly check for ranges
Code Block | ||
---|---|---|
| ||
if(shift_value > 31 or shift_value <0)
throw ArithmeticException;
else
int val = 2 << shift_value;
|
Operations Requiring Really Long Numbers
...