1.BigInteger类概述
可以让超过Integer范围内的数据进行运算。
2.BigInteger类的构造方法
public BigInteger(String val) 将BigInteger的十进制字符串表示形式转换为BigInteger
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38/** * BigInteger类 * 可以让超过Integer范围内的数据进行运算 * 构造方法 * public BigInteger(String val) * 成员方法 * public BigInteger add(BigInteger val) * public BigInteger subtract(BigInteger val) * public BigInteger multiply(BigInteger val) * public BigInteger divide(BigInteger val) * public BigInteger[] divideAndRemainder(BigInteger val) 返回的第一个值为商 第二个值位余数 */ public class BigIntegerDemo { public static void main(String[] args) { BigInteger b1 = new BigInteger("100"); BigInteger b2 = new BigInteger("200"); //public BigInteger add(BigInteger val) System.out.println(b1.add(b2));//300 System.out.println(b1.add(b2));//300 System.out.println(b1.add(b2));//300 System.out.println(b1.add(b2));//300 //public BigInteger subtract(BigInteger val) System.out.println(b1.subtract(b2));//-100 //public BigInteger multiply(BigInteger val) System.out.println(b1.multiply(b2));//20000 //public BigInteger divide(BigInteger val) System.out.println(b1.divide(b2));//0 // public BigInteger[] divideAndRemainder(BigInteger val) BigInteger[] bis = b1.divideAndRemainder(b2); System.out.println(bis[0]);//0 System.out.println(bis[1]);//100 }}
全文:http://www.androidstar.cn/java-biginteger怎么用/
最后
以上就是怕黑故事最近收集整理的关于java biginteger怎么用的全部内容,更多相关java内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复