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

2、BigInteger类的构造方法  

  

3、四则运算

 public static void main(String[] args) {
//大数据封装为BigInteger对象
BigInteger big1 = new BigInteger("12345678909876543210");
BigInteger big2 = new BigInteger("98765432101234567890");
//add实现加法运算
BigInteger bigAdd = big1.add(big2);
//subtract实现减法运算
BigInteger bigSub = big1.subtract(big2);
//multiply实现乘法运算
BigInteger bigMul = big1.multiply(big2);
//divide实现除法运算
BigInteger bigDiv = big2.divide(big1);
}

00075_BigInteger的更多相关文章

随机推荐

  1. HDU4324 Triangle LOVE【拓扑排序】

    Triangle LOVE Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) To ...

  2. HDU 5274(LCA + 线段树)

    Dylans loves tree Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Othe ...

  3. nginx 1.5 支持websocket

    proxy_pass http://backend; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set ...

  4. 33.AngularJS 应用 angular.module定义应用 angular.controller控制应用

    转自:https://www.cnblogs.com/best/tag/Angular/ AngularJS 模块(Module) 定义了 AngularJS 应用. AngularJS 控制器(Co ...

  5. springboot 注入xml自定义类

    新建入口类可扫描类: @Configuration @ImportResource(locations = {"classpath:spring-bean.xml"}) publi ...

  6. 5.不用拷贝的对象可以用ref

    #include <iostream> #include <string> #include <boost/bind.hpp> #include <boost ...

  7. 滑动切换Activity代码

    最近需要对练习项目中的代码进行优化,发现很多代码写起来远比想象的困难很多.刚接触Android时间不长,很多东西都不能融会贯通,所以才会有这样的问题存在,当然学习中遇到的问题很有必要做个总结.想想这个 ...

  8. [转] -- html5手机网站自适应需要加的meta标签

    webapp开发初期,会碰到在pc端开发好的页面在移动端显示过大的问题,这里需要在html head中加入meta标签来控制缩放 <meta name=" viewport" ...

  9. gitHub上如何设置或者取消电子邮箱提醒

    原文链接:点我 我们正常注册的gitHub一般应该都是电子邮箱的方式,在注册账号时可能选择或者默认给了各种提醒,但是gitHub的邮箱提醒真的就比较烦人了,特别是最近团队开发项目,什么动态都有提醒,就 ...

  10. mybatis+springMVC

    !!!springMVC  Mybatis dbcp  log4j 1.导入jar包 2.spring-servlet.xml <?xml version="1.0" enc ...