小编iro*_*man的帖子

C++中1 << 31的模糊结果

当我们运行以下代码时,为什么1<<31打印18446744071562067968输出?

#include<iostream>
using namespace std;

int main(){
    unsigned long long int i = 1<<31;
    cout<<i; // this prints 18446744071562067968
}
Run Code Online (Sandbox Code Playgroud)

c++ bit-manipulation bit-shift bitwise-operators c++11

-2
推荐指数
1
解决办法
165
查看次数