Mark gravell suggested this if you have .NET Core 3, System.Runtime.Intrinsics.X86.Popcnt.PopCount
public bool IsPowerOfTwo(uint i){ return Popcnt.PopCount(i) == 1}
Single instruction, faster than (x != 0) && ((x & (x - 1)) == 0)
but less portable.