创建
BigInteger i1 = new BigInteger("1234567890");
BigInteger i2 = new BigInteger("12345678901234567890");
加减乘除
BigInteger result;
result = i1.add(i2);
result = i1.subtract(i2);
result = i1.multiply(i2);
result = i1.divide(i2);
转换为基本类型
// 转换成 long
BigInteger i = new BigInteger("123456789000");
long v1 = i.longValue(); // 超过了基本类型的范围,转换时将丢失高位信息,即结果不一定是准确的
long v2 = i.longValueExact(); // 准确地转换成基本类型,如果超出了long型的范围,会抛出ArithmeticException
// 其他转换
byteValue()
shortValue()
...