Detect Overflow and Underflow
843811Sep 10 2004 — edited Sep 12 2004Hi all,
How can i delect the overflow or underflow of a int&double value in following example code.
int i = Integer.MAX_VALUE; //Which is 2147483647
int k = i+1; //which is "-2147483648"
int l=Integer.MIN_VALUE; //which is -2147483648
int m = l-1; //which is 2147483647
As you can see the calculation is wrong, how can i catch this event in my code? Which is very important in my program.
Thank you!
Gene Tam