public int diff(int x,int y){
int count=0;
int xor = x^y;
for(int i=0;i<32;i++){
  count += (count>>i)&1;
}return count;
}

Or Integer.bitCount(x^y);

results matching ""

    No results matching ""