• Java常用类库--大数处理类


    源地址:http://blog.sina.com.cn/s/blog_6730a3aa0100xg2m.html

    Java常用类库--大数处理类--BigInteger (2011-10-13 19:53:18)转载▼

    标签: java 常用 类库 -- 大数 处理 类 biginteger 杂谈 分类: Java
    Java常用类库--大数处理类
    ·操作整型:BigInteger类
    ·操作小数:BigDecimal类

    BigInteger类:
    BigInteger类是在java.math包中,方法如下:

    字段摘要
    static BigInteger
    ONE
    BigInteger 的常量 1。
    static BigInteger
    TEN
    BigInteger 的常量 10。
    static BigInteger
    ZERO
    BigInteger 的常量 0。

    构造方法摘要
    BigInteger(byte[] val)
    将包含 BigInteger 的二进制补码表示形式的 byte 数组转换为 BigInteger。
    BigInteger(int signum, byte[] magnitude)
    将 BigInteger 的符号-数量表示形式转换为 BigInteger。
    BigInteger(int bitLength, int certainty, Random rnd)
    构造一个随机生成的正 BigInteger,它可能是一个具有指定 bitLength 的素数。
    BigInteger(int numBits, Random rnd)
    构造一个随机生成的 BigInteger,它是在 0 到 (2numBits - 1)(包括)范围内均匀分布的值。
    BigInteger(String val)
    将 BigInteger 的十进制字符串表示形式转换为 BigInteger。
    BigInteger(String val, int radix)
    将指定基数的 BigInteger 的字符串表示形式转换为 BigInteger。

    方法摘要
    BigInteger
    abs()
    返回其值是此 BigInteger 的绝对值的 BigInteger。
    BigInteger
    add(BigInteger val)
    返回其值为 (this + val) 的 BigInteger。
    BigInteger
    and(BigInteger val)
    返回其值为 (this & val) 的 BigInteger。
    BigInteger
    andNot(BigInteger val)
    返回其值为 (this & ~val) 的 BigInteger。
    int
    bitCount()
    返回此 BigInteger 的二进制补码表示形式中与符号不同的位的数量。
    int
    bitLength()
    返回此 BigInteger 的最小的二进制补码表示形式的位数,不包括 符号位。
    BigInteger
    clearBit(int n)
    返回其值与清除了指定位的此 BigInteger 等效的 BigInteger。
    int
    compareTo(BigInteger val)
    将此 BigInteger 与指定的 BigInteger 进行比较。
    BigInteger
    divide(BigInteger val)
    返回其值为 (this / val) 的 BigInteger。
    BigInteger[]
    divideAndRemainder(BigInteger val)
    返回包含 (this / val) 后跟 (this % val) 的两个 BigInteger 的数组。
    double
    doubleValue()
    将此 BigInteger 转换为 double。
    boolean
    equals(Object x)
    比较此 BigInteger 与指定的 Object 的相等性。
    BigInteger
    flipBit(int n)
    返回其值与对此 BigInteger 进行指定位翻转后的值等效的 BigInteger。
    float
    floatValue()
    将此 BigInteger 转换为 float。
    BigInteger
    gcd(BigInteger val)
    返回一个 BigInteger,其值是 abs(this) 和 abs(val) 的最大公约数。
    int
    getLowestSetBit()
    返回此 BigInteger 最右端(最低位)1 比特的索引(即从此字节的右端开始到本字节中最右端 1 比特之间的 0 比特的位数)。
    int
    hashCode()
    返回此 BigInteger 的哈希码。
    int
    intValue()
    将此 BigInteger 转换为 int。
    boolean
    isProbablePrime(int certainty)
    如果此 BigInteger 可能为素数,则返回 true,如果它一定为合数,则返回 false。
    long
    longValue()
    将此 BigInteger 转换为 long。
    BigInteger
    max(BigInteger val)
    返回此 BigInteger 和 val 的最大值。
    BigInteger
    min(BigInteger val)
    返回此 BigInteger 和 val 的最小值。
    BigInteger
    mod(BigInteger m)
    返回其值为 (this mod m) 的 BigInteger。
    BigInteger
    modInverse(BigInteger m)
    返回其值为 (this-1 mod m) 的 BigInteger。
    BigInteger
    modPow(BigInteger exponent, BigInteger m)
    返回其值为 (thisexponent mod m) 的 BigInteger。
    BigInteger
    multiply(BigInteger val)
    返回其值为 (this * val) 的 BigInteger。
    BigInteger
    negate()
    返回其值是 (-this) 的 BigInteger。
    BigInteger
    nextProbablePrime()
    返回大于此 BigInteger 的可能为素数的第一个整数。
    BigInteger
    not()
    返回其值为 (~this) 的 BigInteger。
    BigInteger
    or(BigInteger val)
    返回其值为 (this | val) 的 BigInteger。
    BigInteger
    pow(int exponent)
    返回其值为 (thisexponent) 的 BigInteger。
    static BigInteger
    probablePrime(int bitLength, Random rnd)
    返回有可能是素数的、具有指定长度的正 BigInteger。
    BigInteger
    remainder(BigInteger val)
    返回其值为 (this % val) 的 BigInteger。
    BigInteger
    setBit(int n)
    返回其值与设置了指定位的此 BigInteger 等效的 BigInteger。
    BigInteger
    shiftLeft(int n)
    返回其值为 (this << n) 的 BigInteger。
    BigInteger
    shiftRight(int n)
    返回其值为 (this >> n) 的 BigInteger。
    int
    signum()
    返回此 BigInteger 的正负号函数。
    BigInteger
    subtract(BigInteger val)
    返回其值为 (this - val) 的 BigInteger。
    boolean
    testBit(int n)
    当且仅当设置了指定的位时,返回 true。
    byte[]
    toByteArray()
    返回一个 byte 数组,该数组包含此 BigInteger 的二进制补码表示形式。
    String
    toString()
    返回此 BigInteger 的十进制字符串表示形式。
    String
    toString(int radix)
    返回此 BigInteger 的给定基数的字符串表示形式。
    static BigInteger
    valueOf(long val)
    返回其值等于指定 long 的值的 BigInteger。
    BigInteger
    xor(BigInteger val)
    返回其值为 (this ^ val) 的 BigInteger。
  • 相关阅读:
    经典的笔试题python操作数据库和python设计模式【多测师_王sir】
    上证所python笔试题【多测师_王sir】
    银行移动消费信贷业务梳理【多测师_王sir】
    查看log.txt 日志文件中包含关键字x123或者x124的行,以及该行前后10行内容,并输出到out.txt中【多测师_王sir】【Linux题目】
    文件权限设置
    windows OpenSSH WARNING: UNPROTECTED PRIVATE KEY FILE!
    vue对象合并
    elk安装配置
    ElasticSearch
    Elastic Search之Search API(Query DSL)、字段类查询、复合查询
  • 原文地址:https://www.cnblogs.com/codeyuan/p/4254415.html
Copyright © 2020-2023  润新知