我已经使用c++
超过3个月了,我无法找出long long int
中数字的确切最大值。
有人知道值(value)吗?
最佳答案
这取决于系统。 C++标准仅保证long long int
will be 64-bits的最小大小。到目前为止,这也是最常见的大小。
如果使用64位大小,则可以表示的最大数量为2^63 - 1
,等于9223372036854775807
。之所以如此精确,是因为我们需要一半的组合位用于负数,然后一个用于0
,其余的用于正数。
特定系统上的最大值还可以通过以下方式通过程序检查:
#include <iostream>
#include <limits>
int main() {
std::cout << std::numeric_limits<long long int>::max();
}
Output:
9223372036854775807
关于c++ - C++中 `long long int`的确切最大值是多少?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58710120/