Built-in Function: int __builtin_ffs (unsigned int x)
ffs - find first bit set
Returns one plus the index of the least significant 1-bit of x, or if x is zero, returns zero.
x的最后一位1是从后向前第几位,位置从1计数,找不到返回0;
— Built-in Function: int __builtin_clz (unsigned int x)
Returns the number of leading 0-bits in x, starting at the most significant bit position. If x is 0, the result is undefined.
统计左起第一个‘1’之前(头部)0的个数。
— Built-in Function: int __builtin_ctz (unsigned int x)
Returns the number of trailing 0-bits in x, starting at the least significant bit position. If x is 0, the result is undefined.
统计右起第一个‘1’之后(尾部)的0的个数。
— Built-in Function: int __builtin_popcount (unsigned int x)
Returns the number of 1-bits in x.
返回‘1’的个数。
— Built-in Function: int __builtin_parity (unsigned int x)
Returns the parity of x, i.e. the number of 1-bits in x modulo 2.
返回x的奇偶校验位,也就是x中1的个数模2的结果。
另外,函数名后加 l,参数为unsigned long
,加 ll,为unsigned long long
。
— Built-in Function: int __builtin_ffsl (unsigned long)
— Built-in Function: int __builtin_ffsll (unsigned long long)