在Java中,long类型的最大值是9223372036854775807,那么请设计如何计算9223372036854775807+9223372036854
如题,各位可有什么想法?谢谢
[解决办法]
java.lang.BigInteger
[解决办法]
- Java code
String str="9223372036854775807"; String str1="9223372036854"; BigInteger bi1=new BigInteger(str); BigInteger bi2=new BigInteger(str1); BigInteger result=bi1.add(bi2); System.out.println(result.toString());
[解决办法]
用的 用 java.lang.BigInteger
是作的,就用 Long Array 大相加算法。