/** * Add two long integers, checking for overflow. * * @param a an addend * @param b an addend * @return the sum <code>a+b</code> * @throws org.matheclipse.parser.client.math.MathException if the result * can not be represented as an long * @since 1.2 */ public static long addAndCheck( long a, long b ) { return addAndCheck( a, b, "overflow: add" ); }
/** * Add two long integers, checking for overflow. * * @param a * an addend * @param b * an addend * @return the sum <code>a+b</code> * @throws MathException * if the result can not be represented as an long * @since 1.2 */ public static long addAndCheck(long a, long b) { return addAndCheck(a, b, "overflow: add"); }
/** * Add two long integers, checking for overflow. * * @param a * an addend * @param b * an addend * @return the sum <code>a+b</code> * @throws MathException * if the result can not be represented as an long * @since 1.2 */ public static long addAndCheck(long a, long b) { return addAndCheck(a, b, "overflow: add"); }
/** * Subtract two long integers, checking for overflow. * * @param a * first value * @param b * second value * @return the difference <code>a-b</code> * @throws MathException * if the result can not be represented as an long * @since 1.2 */ public static long subAndCheck(long a, long b) { long ret; String msg = "overflow: subtract"; if (b == Long.MIN_VALUE) { if (a < 0) { ret = a - b; } else { throw new MathException(msg); } } else { // use additive inverse ret = addAndCheck(a, -b, msg); } return ret; }
/** * Subtract two long integers, checking for overflow. * * @param a * first value * @param b * second value * @return the difference <code>a-b</code> * @throws MathException * if the result can not be represented as an long * @since 1.2 */ public static long subAndCheck(long a, long b) { long ret; String msg = "overflow: subtract"; if (b == Long.MIN_VALUE) { if (a < 0) { ret = a - b; } else { throw new MathException(msg); } } else { // use additive inverse ret = addAndCheck(a, -b, msg); } return ret; }
/** * Subtract two long integers, checking for overflow. * * @param a first value * @param b second value * @return the difference <code>a-b</code> * @throws org.matheclipse.parser.client.math.MathException if the result * can not be represented as an long * @since 1.2 */ public static long subAndCheck( long a, long b ) { long ret; String msg = "overflow: subtract"; if ( b == Long.MIN_VALUE ) { if ( a < 0 ) { ret = a - b; } else { throw new MathException( msg ); } } else { // use additive inverse ret = addAndCheck( a, -b, msg ); } return ret; }
if (a > b) { ret = addAndCheck(b, a, msg); } else {
if (a > b) { ret = addAndCheck(b, a, msg); } else {
if ( a > b ) { ret = addAndCheck( b, a, msg );