/*
 * Overflow checking.
 * adds the two parameters, throwing a MyOverflowException if the result is not an int.
 * @param a first operand to add
 * @param b second operand to add
 * @result a + b
 */
public static int addSafe(int a, int b ) throws MyOverflowException {
   if ( ( a > 0 && b > Integer.MAX_VALUE - a) || ( a < 0 && b < Integer.MIN_VALUE - a ) )
      {
      throw new MyOverflowException( a + " + " + b + " = " + ( (long)a + (long)b ) );
      }
   return a + b;
}