BigInteger
- java.math.BigInteger 类,不可变的任意精度的整数。如果运算中,数据的范围超过了 long 类型后,可以使用 BigInteger 类实现,该类的计算整数是不限制长度的;
 - 详见:Class BigInteger ,注意不是继承 Math 类,而是继承自 Number;

 
1. 构造方法
- BigInteger(String value) 将 BigInteger 的十进制字符串表示形式转换为 BigInteger,超过 long 类型的范围,已经不能称为数字了,因此构造方法中采用字符串的形式来表示超大整数,将超大整数封装成 BigInteger 对象;
 
2. 成员方法
- BigInteger 类提供了对很大的整数进行加、减、乘、除的方法,注意:都是与另一个 BigInteger 对象进行运算;
 
| 方法声明 | 描述 | 
|---|---|
| add(BigInteger value) | 返回其值为 (this + val) 的 BigInteger,超大整数加法运算 | 
| subtract(BigInteger value) | 返回其值为 (this - val) 的 BigInteger,超大整数减法运算 | 
| multiply(BigInteger value) | 返回其值为 (this * val) 的 BigInteger,超大整数乘法运算 | 
| divide(BigInteger value) | 返回其值为 (this / val) 的 BigInteger,超大整数除法运算,除不尽取整数部分 | 
3. Java 实例
import java.math.BigInteger;
public class test {
    public static void main(String[] args) {
        BigInteger big1 = new BigInteger("8327432493258329432643728320843");
        BigInteger big2 = new BigInteger("98237473274832382943274328834");
        //加法运算
        BigInteger add = big1.add(big2);
        System.out.println("求和:" + add);
        //减法运算
        BigInteger sub = big1.subtract(big2);
        System.out.println("求差:" + sub);
        //乘法运算
        BigInteger mul = big1.multiply(big2);
        System.out.println("乘积:" + mul);
        //除法运算
        BigInteger div = big1.divide(big2);
        System.out.println("除法:" + div);
    }
}
                                    来源:CSDN
作者:Regino
链接:https://blog.csdn.net/Regino/article/details/104604043
