请教一个奇怪的溢出的问题
  • 板块灌水区
  • 楼主mooktian
  • 当前回复6
  • 已保存回复6
  • 发布时间2023/8/6 14:27
  • 上次更新2023/11/3 05:35:44
查看原帖
请教一个奇怪的溢出的问题
890321
mooktian楼主2023/8/6 14:27

DEV C++ 5.11版本,win7操作系统

#include <bits/stdc++.h>
using namespace std;
int main(){
	unsigned long long n;
	n = 1 << 31;
	cout << n;
    return 0;
}

输出为:18446744071562067968

#include <bits/stdc++.h>
using namespace std;
int main(){
	long long n;
	n = 1 << 31;
	cout << n;
    return 0;
}

输出为:-2147483648

真是奇了怪了。

2023/8/6 14:27
加载中...