zoukankan      html  css  js  c++  java
  • Java BigInteger类知识点总结

    (1)程序有时需要处理大整数,java.math包中的BigInteger类提供任意精度的整数运算,可以使用构造方法:

    public BigInteger(String VAL)构造一个十进制的BigInteger对象,该构造方法可以发生NumberFormatException异常,也就是说,字符串参数VAL中如果含有非数字字符就会发生NumberFormatException异常。

    (2)BigInteger类的常用方法:

    public BigInteger add(BigInteger val)   返回当前大整数对象与参数指定的大整数对象的和

    public BigInteger subtract(BigInteger val)  返回当前大整数对象与参数指定的大整数对象的差

    public BigInteger multiply(BigInteger val)   返回当前大整数对象与参数指定的大整数对象的积

    public BigInteger devide(BigInteger val)    返回当前大整数对象与参数指定的大整数对象的商

    public BigInteger remainder(BigInteger val)    返回当前大整数对象与参数指定的大整数对象的余

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

    public BigInteger abs()    返回当前大整数对象的绝对值

    public BigInteger pow(int exponent)   返回当前大整数对象的exponent次幂。

    public String toString()    返回当前当前大整数对象十进制的字符串表示。

    public String toString(int p)   返回当前大整数对象p进制的字符串表示。

    (3)

  • 相关阅读:
    Matlab从入门到精通 Chapter5 数据可视化
    给source insight添加.cc的C++文件后缀识别
    机构研究报告
    配置Haproxy
    Ceph:一个 Linux PB 级分布式文件系统
    Centos安装源包出错Package xxx.rpm is not signed
    [虚拟机] 小实验: 使用KVM虚拟机,安装一个windows系统
    关于北京地铁通车计划
    python字符串和数字的基本运算符 valar
    python种类 valar
  • 原文地址:https://www.cnblogs.com/zengfanye/p/9495989.html
Copyright © 2011-2022 走看看