@fabrizio3

yes,just for example：

-5：11111111 11111111 11111111 11111011 (complement)

-5>>1：11111111 11111111 11111111 11111101 (-3)

-5>>>1：01111111 11111111 11111111 11111101 (2147483645)

so you can clearly see the difference：

the >> needs to consider the sign bit,so the mising bit is always 1.

and >>> doesn't need to consider it,and the mising bit is replaced by 0.

so if you don't wanna use >>> but >>,we can count 32 times

and the using Integer.bitCount() one

public class Solution { // you need to treat n as an unsigned value public int hammingWeight(int n) { return Integer.bitCount(n);