因此,当我偶然发现一个小“问题”(示例来自 C++ Primer 第 6 版)时,我正在用新的数据类型long long进行一些测试。我正在使用 climits 库来告诉我long和long long支持的最大数量,结果都是 9223372036854775807。这怎么可能?
#include <iostream>
#include <climits>
int main()
{
std::cout << "int size is " << sizeof(int) << " bytes." << std::endl;
std::cout << "short size is " << sizeof(short) << " bytes." << std::endl;
std::cout << "long size is " << sizeof(long) << " bytes." << std::endl;
std::cout << "long long size is " << sizeof(long long) << " bytes." << std::endl;
std::cout << "Maximum values: " << std::endl;
std::cout << "int: " << INT_MAX << std::endl;
std::cout << "short: " << SHRT_MAX << std::endl;
std::cout << "long: " << LONG_MAX << std::endl;
std::cout << "long long: " << LLONG_MAX << std::endl;
return 0;
}