n is a power of 2 ?

来源:互联网 发布:iptables开放3306端口 编辑:程序博客网 时间:2024/05/17 20:26
/* Returns true if n is a power of 2 */
static inline int
is_power_of_2(uint32_t n)
{
return ((n-1) & n) == 0;
}