News for hackers. Stuff that matters.
Re:Ten Ways to Check if an Integer Is a Power Of Two in C by ChristianMarks on Tuesday July 26, 2011 @12:06PM (#2807965)
The decrement test for a power of two can be modified to count bits and runs in log n time.

  int bits(unsigned n)
  {
     int i = 0;
     while (n > 0) { n &= n-1; i++ } 
     return i;
  }
Re:Ten Ways to Check if an Integer Is a Power Of Two in C by axylone on Tuesday July 26, 2011 @04:42PM (#2809411)