BigInteger概述
可以让超过Integer范围内的数据进行运算
其范围可以无限位,只要你的内存够大。
构造方法
public BigInteger(String val)
成员方法
public BigInteger add(BigInteger val) // 加
public BigInteger subtract(BigInteger val) //减
public BigInteger multiply(BigInteger val) //乘
public BigInteger divide(BigInteger val) //除
代码显示:
public static void main(String[] args) {
// TODO Auto-generated method stub
BigInteger b1 = new BigInteger("100");
BigInteger b2 = new BigInteger("20");
System.out.println(b1.add(b2));//加
System.out.println(b1.subtract(b2));//减
System.out.println(b1.multiply(b2));//乘
System.out.println(b1.divide(b2));//除
}
结果:
120
80
2000
5