```
public class Solution {
public int getSum(int a, int b) {
int carry = 0;
int result = 0;
for (int i=0; i<32; i++) {
int d1 = (a>>i)&1;
int d2 = (b>>i)&1;
//111, 110, 100, 000
//d3:1, 0, 1, 0
//carry: 1, 1, 0, 0
int d3 = d1^d2^carry;
if ( (d1&d2)==1||(d1&carry)==1||(d2&carry)==1 )
carry = 1;
else carry = 0;
result = result | d3<<i;
}
return result;
}
}
```