Suppose there are given two integers, a and b, and we know that a>b. I want to calculate how many operations I should make on b to get a (by operation I mean that bitwise operations change a bit from 1 to 0 and vice versa. How can I count the number of operation for such a transform?
Share
What you are looking is called the Hamming distance. Here is how I compute it in C/C++: