// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
public class ShiftFun2 {
    public static int test(int a, int b) {
        int c = (a + b) >>> 1;
        return c;
    }
    public static int testx(int a, int b) {
        int c = 0x7FFFFFFF & ((a + b) >> 1);
        return c;
    }
    public static void wrap(int i) {
        if(test(0, i) != testx(0, i)) {
            System.out.println("Problem with " + i);
        }
    }
    public static void main(String[] args) {
        for(int i = Integer.MIN_VALUE; i < Integer.MAX_VALUE; i++) {
            wrap(i);
        }
        wrap(Integer.MAX_VALUE);
        System.out.println("All done");
    }
}
