Here you can find the source of unsignedAddOverflow(int operand1, int operand2)
public static boolean unsignedAddOverflow(int operand1, int operand2)
//package com.java2s; /*/* www . java2 s .c o m*/ * This file is part of MRP (http://mrp.codehaus.org/). * * This file is licensed to You under the Eclipse Public License (EPL); * You may not use this file except in compliance with the License. You * may obtain a copy of the License at * * http://www.opensource.org/licenses/eclipse-1.0.php * * See the COPYRIGHT.txt file distributed with this work for information * regarding copyright ownership. */ public class Main { /** * Returns true, if the addition of both operands as unsigned integers will cause an overflow. * At the moment, this converts both values to longs and checks if the 33rd bit (which actually represents the carry) * overflows. */ public static boolean unsignedAddOverflow(int operand1, int operand2) { long value1 = (long) operand1 & 0xFFFFFFFFL; long value2 = (long) operand2 & 0xFFFFFFFFL; return ((value1 + value2) & 0x100000000L) != 0; } }