1
#include <iostream>
#include <stdint.h>
using namespace std;
typedef __int128_t int128_t;
int main() {
  int128_t y = 0;
  cout<<__builtin_clzll(static_cast<unsigned long long>(y>>64)) <<endl;
  cout<<__builtin_clzll(static_cast<unsigned long long>(0)) <<endl;
}

输出:63 64

gcc 版本 5.3.0 20151204

为什么结果是错误的?有没有其他方法可以计算 int128_t 的前导零。

4

0 回答 0