Robert

Robert

  • NA
  • 1
  • 0

Help with Bit Operation

May 3 2009 12:07 AM
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