Basic usage of BigInteger and BigDecimal

Integer large numbers 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); // large integer multiplication 
             BigInteger div = aa.divide (bb);    // large integer addition 
             System.out.println (sub.toString ()); 
             System.out.println (add.toString ()); 
             System. Out.println (mul.toString ()); 
             System.out.println (div.toString ()); 
    } 
}

BigDecimal floating point arithmetic usage with large numbers BigInteger

Guess you like

Origin www.cnblogs.com/qdu-lkc/p/12189215.html
Recommended