BigInteger和BigDecimal的基本用法

整型大数 BigInteger:

import java.math.BigInteger;
import java.util.Scanner;
public class Main {
       public static void main(String[] args) {
             Scanner scan=new Scanner(System.in);
             BigInteger aa =new BigInteger("100");
             BigInteger bb= new BigInteger("25");
             BigInteger sub=aa.subtract(bb); //大整数的减
             BigInteger add=aa.add(bb);      //大整数的加
             BigInteger mul=aa.multiply(bb); //大整数的乘
             BigInteger div=aa.divide(bb);   //大整数的除
             System.out.println(sub.toString());
             System.out.println(add.toString());
             System.out.println(mul.toString());
             System.out.println(div.toString());
    }
}

浮点型大数 BigDecimal 加减乘除用法 同BigInteger

猜你喜欢

转载自www.cnblogs.com/qdu-lkc/p/12189215.html