How to determine whether a number is 2^[INTEGER]?

• 本文约 49 字,阅读大致需要 1 分钟 | Development

I have an idea: let we have “a” is the number to determine.

return ( (0 == (a & (a-1))) && (a > 0))

Despite the style of the code, is there some better solution? Note that a is a native integer type (say, int, long, long long, etc).