小编Pho*_*xGS的帖子

为什么 C++ 中 `printf("%llu\n", 1ull << n);` 和 `printf("%llu\n", 1ull << 64);` 的输出不同?(n=64)

为什么C++中printf("%llu\n", 1ull << n);和的输出printf("%llu\n", 1ull << 64);不同?

代码:

#include <cstdio>

int main()
{
    int n = 64;
    printf("%llu\n", 1ull << n);
    printf("%llu\n", 1ull << 64);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

输出:

1
0
Run Code Online (Sandbox Code Playgroud)

c c++ bit-shift undefined-behavior

7
推荐指数
2
解决办法
227
查看次数

标签 统计

bit-shift ×1

c ×1

c++ ×1

undefined-behavior ×1