码迷,mamicode.com
首页 > 其他好文 > 详细

00075_BigInteger

时间:2017-12-23 16:03:22      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:static   png   ati   post   []   .com   除法   gdi   image   

1、Java中long型为最大整数类型,对于超过long型的数据如何去表示呢.在Java的世界中,超过long型的整数已经不能被称为整数了,它们被封装成BigInteger对象.在BigInteger类中,实现四则运算都是方法来实现,并不是采用运算符。

2、BigInteger类的构造方法  

  技术分享图片

3、四则运算

 1 public static void main(String[] args) {
 2         //大数据封装为BigInteger对象
 3           BigInteger big1 = new BigInteger("12345678909876543210");
 4           BigInteger big2 = new BigInteger("98765432101234567890");
 5           //add实现加法运算
 6           BigInteger bigAdd = big1.add(big2);
 7           //subtract实现减法运算
 8           BigInteger bigSub = big1.subtract(big2);
 9           //multiply实现乘法运算
10           BigInteger bigMul = big1.multiply(big2);
11           //divide实现除法运算
12           BigInteger bigDiv = big2.divide(big1);
13 }

 

00075_BigInteger

标签:static   png   ati   post   []   .com   除法   gdi   image   

原文地址:http://www.cnblogs.com/gzdlh/p/8093379.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!