public static int sum(int a, int b) {
        int carry = 0;
        int sum = 0;
        for( int bit = 0 ; bit < 32; bit++) {
            int x = ((1<< bit) & a) != 0 ? 1: 0 ;
            int y = ((1 << bit) & b) != 0 ? 1: 0;
            int z = x^y;
            if(z == 0) {
                z = carry;


                carry = x == 0 ? 0 : 1;
            } else {
                z = carry == 0? 1 : 0;

                carry = carry == 0? carry : 1;
            }
            sum  = sum | (z << bit);



        }


       return sum;

    }