Comments

If we make XOR between a and a without the leftmost bit we will obtain a number that only the leftmost bit of a will be active because the rest of the bits will be equal. the log_2 of this number is the position of this bit

__lg( a ^ (a & (a — 1)) )