0 is not a power of 2
Matthias Bentrup via Digitalmars-d
digitalmars-d at puremagic.com
Tue May 19 13:46:08 PDT 2015
I think you can make the over/underflow at zero work in your
favor:
bool isPowerOf2(uint x)
{
return (x & -x) > (x - 1);
}
More information about the Digitalmars-d
mailing list