Question 2 Determine the number of bits that are different between two integers
// Some code
int numberOfDifferentBits(int a, int b) {
int x = a ^ b;
int count = 0;
while (x != 0) {
count += x& 1;
x = x>>> 1; //右移,左侧补零
}
}PreviousQuestion 1 determine wheter a number x is a power of 2NextQuestion3 What happens if we assign a negative number to an unsigned integer
Last updated