首页 > 其他 > 详细

BigInteger和BigDecimal的基本用法

时间:2020-01-13 21:18:09      阅读:98      评论:0      收藏:0      [点我收藏+]

整型大数 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

BigInteger和BigDecimal的基本用法

原文:https://www.cnblogs.com/qdu-lkc/p/12189215.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!