package core1;
import java.math.BigDecimal;
import java.math.BigInteger;
public class D03_BigNumber {
public static void main(String[] args){
BigInteger bInt = new BigInteger("100");
BigDecimal bDec = new BigDecimal("99.909");
System.out.println("bInt = " + bInt);
System.out.println("bDec = " + bDec);
/*
* .遗憾的是,这两种任意长度的类型不支持基本运算符+-,其运算需要通过add、multiply等成员函数
* */
System.out.println("bInt * 33 = " + bInt.multiply(new BigInteger("33")));
System.out.println("bDec + 1.1 = " + bDec.add(new BigDecimal("1.1")));
}
}
console输出
bInt = 100
bDec = 99.909
bInt * 33 = 3300
bDec + 1.1 = 101.009