一:如何得到比long类型还大的值
-
BigInteger:大整型
-
不可变的任意精度的整数。
public static void main(String[] args) { //long max = Long.MAX_VALUE; /*System.out.println(max); System.out.println(max+1);*/ // 将 BigInteger 的十进制字符串表示形式转换为 BigInteger。 BigInteger bg = new BigInteger("9223372036854775807"); bg = bg.add(new BigInteger("13241654654654198498419848 9498498498494984984984984984984")); System.out.println(bg); }
获取比double最大值还要大的数字
-
BigDecimal:大浮点型
public static void main(String[] args) { /*double max = Double.MAX_VALUE; System.out.println(max); System.out.println(max+max);*/ BigDecimal bd = new BigDecimal("1.7976931348623157E308"); bd = bd.add(new BigDecimal("1.7976931348623157E308")); System.out.println(bd); }