Q:

Count number of bits to be flipped to convert A to B

Suppose, I have two numbers A and B. I need to find out how many numbers of bits needed to be changed to convert A to B.
Like:
A = 1101101
B = 1011011
     ^^ ^^

Here, we need to change 4 bits to convert A to B
How can I do this?

A:

You can simply do this :
int need=__builtin_popcountll(A^B);
cout<<need;

