delphij's Chaos

选择chaos这个词是因为~~实在很难找到一个更合适的词来形容这儿了……

30 May 2005

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

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).