Today I needed a simple algorithm for checking if a number is a power of 2.
The algorithm needs to be:
ulong
private static bool IsPowerOfTwo(ulong x) { var l = Math.Log(x, 2); return (l == Math.Floor(l)); }