```
public class Solution {
public int hammingWeight(int n) {
int t=0;
if(n<0){
n=-n-1;
while(n!=0){
if(n%2==1) t++;
n=n/2;
}
return 32-t;
}
while(n!=0){
if(n%2==1) t++;
n=n/2;
}
return t;
}
}
```