@@ -0,0 +1,1712 @@
+package test.io.dindinw.lang;%0A%0Aimport java.math.BigInteger;%0Aimport java.util.Arrays;%0A%0Aimport org.junit.Test;%0A%0Aimport static org.junit.Assert.assertEquals;%0A%0A/**%0A * Usage of %3E%3E %3E%3E%3E %3C%3C%0A */%0Apublic class ShiftTest %7B%0A%0A    @Test%0A    public void testDouble() %7B%0A        for (int i = 0; i %3C Integer.MAX_VALUE; i++) %7B%0A            assertEquals(i * 2, Double(i));%0A            assertEquals(-i * 2, Double(-i));%0A        %7D%0A    %7D%0A%0A    /**%0A     * @param i integer%0A     * @return i*2%0A     */%0A    private static int Double(int i) %7B%0A        return i %3C%3C 1;%0A    %7D%0A%0A    @Test%0A    public void testBase2power() %7B%0A        Arrays.stream(new int%5B%5D%7B1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13%7D).map((x) -%3E %7B%0A            int base2pow = base2pow(x);%0A            assertEquals(BigInteger.valueOf(2).pow(x).intValue(), base2pow);%0A            System.out.printf(%221%3C%3C%25s%5Ct= 2%5E%25s%5Ct= %25s%5Cn%22,x,x,base2pow);%0A            return base2pow;%0A        %7D).toArray();%0A    %7D%0A%0A    /**%0A     * a power is represented with a base number and an exponent.%0A     * The base number tells what number is being multiplied.%0A     * The exponent, a small number written above and to the%0A     * right of the base number, tells how many times the base%0A     * number is being multiplied.%0A     * @param exponent the times of 2 is being multiplied%0A     * @return 2%5Eexp%0A     */%0A    private static int base2pow(int exponent) %7B%0A        return 1 %3C%3C exponent;%0A    %7D%0A%0A    /**%0A     *%0A     * @param n should be 2, 4, 8, 16 ...%0A     * @return 1,2,3,4%0A     */%0A    private static int base2log(int n)%7B%0A        if(n %3C= 0) throw new IllegalArgumentException();%0A        return 31 - Integer.numberOfLeadingZeros(n);%0A    %7D%0A%0A    @Test%0A    public void testLog()%7B%0A        assertEquals(3,base2log(8));%0A    %7D%0A%0A%7D%0A

test for left-shift