```
def hammingWeight1(self, n):
res = 0
for i in xrange(32):
# res += (n & 1 << i != 0)
res += (n >> i & 1)
return res
def hammingWeight(self, n):
res = 0
while n:
res += n&1
n /= 2
return res
```