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. 13款用于拍摄全景照片的iOS应用

    全景图是一种大画幅.用来展示尽量多的周围环境的照片,甚至能够展示一个球状的完整空间,让观赏者直接“站在”摄影师的位置,在照片里将该环境一览无余.全景照片能够以最直观的方式向人们展示和记录一个美丽风景的 ...

  2. HDU 5303 Delicious Apples (2015多校第二场 贪心 + 枚举)

    Delicious Apples Time Limit: 5000/3000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Other ...

  3. Reading and writing

    A text file is a sequence of characters stored on a permanent medium like a hard drive, flash memory ...

  4. Lists and strings

    A string is a sequence of characters and a list is a sequence of values, but a list of characters is ...

  5. A list is a sequence

    Like a string, a list is a sequence of values. In a string, the values are characters; in a list, th ...

  6. java中"".equals(A)与A.equals("")一样不?

    不一样如果a为nulla = null;a.equals("")出错nullPointerException如果写为"".equals(a)-->就可以防 ...

  7. OpenGL编程逐步深入(八)伸缩变换

    准备知识 伸缩变换非常简单,它的目的是增大或者缩小对象的尺寸.例如:你可能希望用同一个模型创建不同大小的对象(例如形状相同,但大小不同的树木)或者你想改变对象的大小使它和游戏场景匹配.这些例子中你可能 ...

  8. 洛谷 P4148 简单题 KD-Tree 模板题

    Code: //洛谷 P4148 简单题 KD-Tree 模板题 #include <cstdio> #include <algorithm> #include <cst ...

  9. iOS开发——国际化支持Localizable.strings

    这篇写的不多,但是绝对诚意满满.不会像别人一样,要不不详细,要不罗里吧嗦一堆. 1.创建Localizable.strings文件 Command+N—>iOS—>Resource—> ...

  10. bzoj 1588 [HNOI2002] 营业额统计 链表和Splay

    来自HNOI 2002营业额的统计一题,这题以前是用链表水过的,最近看见许多splay的题,赶紧张一下知识. 题目大意就是对于一个序列,输出每个元素与它之前元素的差的最小值的和.先说链表的方法吧. 大 ...