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 .