package cn.lz.base;
import java.math.BigDecimal;
import java.math.BigInteger;
/**
*
* 高精度数字
* @author lzzz
*
*/
public class J17100802 {
public static void main(String[] args) {
BigInteger a1 = new BigInteger("19181716151413121110987654321");
BigInteger a2 = new BigInteger("12345678910111213141516171819");
// 加法
System.out.println(a1.add(a2)); // 31527395061524334252503826140
// 乘法
System.out.println(a1.multiply(a2)); // 236811308550240594910066199325923006903586430678413779899
// int a3 = 12345678910111213141516171819;
/*
* Exception in thread "main" java.lang.Error: Unresolved compilation problem:
* The literal 12345678910111213141516171819 of type int is out of range
*/
BigDecimal b1 = new BigDecimal("12345678910111213141516171819.12345678910111213141516171819");
BigDecimal b2 = new BigDecimal("12345678910111213141516171819.12345678910111213141516171819");
// 乘法
System.out.println(b1.multiply(b2)); // 152415787751564791571474464065423486394871076136159258042.2627449915719520852517428216262375170639839780304729768761
}
}