I think you can make the over/underflow at zero work in your favor:

bool isPowerOf2(uint x)
{
  return (x & -x) > (x - 1);
}

Reply via email to