Today I needed a simple algorithm for checking if a number is a power of 2.
The algorithm needs to be:
ulong
Here's a simple C++ solution:
bool IsPowerOfTwo( unsigned int i ) { return std::bitset<32>(i).count() == 1; }