0
Reply

Help with Bit Operation

Robert

Robert

May 3 2009 12:07 AM
2.3k
Hello, assuming I have a value of n that is a power of 2, what is the quickest way to find which bit is set?
Is there anything faster than a simple iteration such as

int temp = 0;
for (int i = n; i > 1; i >>= 1, temp++) { }

Thanks