I am looking for an efficient way to determine the position of the least significant bit that is set in an integer, e.g. for 0x0FF0 it would be 4.
A trivial impleme
Here is one simple alternative, even though finding logs is a bit costly.
if(n == 0) return 0; return log2(n & -n)+1; //Assuming the bit index starts from 1