Today I needed a simple algorithm for checking if a number is a power of 2.
The algorithm needs to be:
ulong
bool isPow2 = ((x & ~(x-1))==x)? !!x : 0;