众所周知,以 __builtin 开头的函数,是一种相当神奇的位运算函数,下面本人盘点了一下这些以 __builtin 开头的函数,希望可以帮到大家。
注:所有带 ll 的名字,均为 long long 类型下运算,否则将当作 int 来算。
1 __builtin_ctz( ) / __buitlin_ctzll( )
用法:返回括号内数的二进制表示形式中末尾0的个数。
举个例子:
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout<<__builtin_ctz(64)<<endl;
return 0;
}
输出:6
64=,末尾共有6个0。