BigInteger类

java.math.BigInteger类的构造方法:

1.public BigInteger(String val) throws NumberFormatException

构造一个十进制的BigInteger对象,参数val如果含有非数字字符就会发生异常;

 

Java中BigInteger类的常用方法:

1.public BigInteger add(BigInteger val)

返回当前大整数对象与参数val指定的大整数对象的和;

2.public BigInteger subtract(BigInteger val)

返回当前大整数对象与参数val指定的大整数对象的差;

3.public BigInteger multiply(BigInteger val)

返回当前大整数对象与参数val指定的大整数对象的积;

4.public BigInteger divide(BigInteger val)

返回当前大整数对象与参数val指定的大整数对象的商;

5.public BigInteger remainder(BigInteger val)

返回当前大整数对象与参数val指定的大整数对象的余;

6.public int compareTo(BigInteger val)

返回当前大整数对象与参数指定的大整数的比较结果,返回值是1、-1、0,分别表示当前大整数对象大于、小于或等于参数val指定的大整数;

7.public BigInteger abs()

返回当前大整数对象的绝对值;

8.public BigInteger pow(int a)

返回当前大整数对象的a次幂;

9.public String toString()

返回当前大整数对象十进制的字符串表示;

10.public String toString(int p)

返回当前大整数对象p进制的字符串表示;

转载于:https://www.cnblogs.com/rongbin/p/9370125.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值