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.
[ Parent
| on HN ]
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)
Much better ways to count bits set: http://graphics.stanford.edu/~seander/bithacks.html#CountBit...