public static int addInBounds(int value, int added) {
        int avail = Integer.MAX_VALUE - value;
        if (avail < added) {
            return added - avail;
        } else {
            return value + added;
        }
    }
public static int addInBounds ( int value , int added ) { int avail = Integer . MAX_VALUE - value ; if ( avail < added ) { return added - avail ; } else { return value + added ; } }
Add integers modulo MAX_VALUE.

@param value base integer
@param added value that is added to the base value
@return (value plus added) modulo Integer.MAX_VALUE