I'm looking for an efficient method (preferably using few bitwise operations) that returns the count of left shifts or solve the equation as:
find x for a given y where y=2^x
For example (1 << 4) = 16 = 10000b. So if 16 is given how can I solve it for the amount of left shift which is 4 in given case. Also, I'm not looking for a method that involves loop or log method like:
unsigned int count_shift(unsigned int shifted)
{
unsigned int count = 0;
for (count = 0; shifted != 0x1; count++)
{
shifted /= 2;
}
return count;
}
Cheers!