在 Java 或 C++ 中是否有任何数据类型可以保存 20 位或更多位的整数值? long long 数据类型只能保存到 18 位。
最佳答案
Java 特定:
你正在寻找BigInteger
Immutable arbitrary-precision integers. All operations behave as if BigIntegers were represented in two's-complement notation (like Java's primitive integer types)
例如:
BigInteger bint = new BigInteger("1234567856656569");
BigInteger bint2 = new BigInteger("1234556567856656569");
System.out.println(bint2.intValue()-bint.intValue()); //397189120
还有 BigDecimal
关于java - c++ 或 java 中用于保存 20 位整数的数据类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20772486/