bool IsPowerOfTwo(ulong x){ return x > 0 && (x & (x - 1)) == 0;}
↧
Answer by Matt Howells for How to check if a number is a power of 2
↧
bool IsPowerOfTwo(ulong x){ return x > 0 && (x & (x - 1)) == 0;}