```
public class Solution {
// you need to treat n as an unsigned value
public int hammingWeight(int n) {
int returnVal = 0;
do{
if(n % 2 == 1)
returnVal++;
n/=2;
}while(n != 0);
return returnVal;
}
}
```

after running it, I got 0 on the input of 2147483648. But it should return 1, since after n = 2 loop, the n/2 = 1 which is not 0 and the loop is still going, and then 1%2 == 1 will trigger the if and returnVal++ will be executed. I then tried this code on eclipse, where it tells me the input number 2147483648 is out of range of the type int. Can anyone explain what went wrong here?

Thanks a lot!