| 返回类型 | 方法描述 |
|---|---|
| 计算 | |
| BigInteger | abs()
返回绝对值 |
| BigInteger | add(BigInteger val)
加法,(this + val) |
| BigInteger | subtract(BigInteger val)
减法,(this - val) |
| BigInteger | multiply(BigInteger val)
乘法, (this * val) |
| BigInteger | divide(BigInteger val)
除法取商, (this / val) |
| BigInteger | remainder(BigInteger val)
除法取余, (this % val) |
| BigInteger[] | divideAndRemainder(BigInteger val)
除法,返回数组, 商array[0] = (this / val),余数array[1] (this % val) |
| BigInteger | pow(int exponent)
次方计算 |
| 位操作 | |
| BigInteger | and(BigInteger val)
按位与 |
| BigInteger | not()
取非,返回非值 (~this) |
| BigInteger | or(BigInteger val)
按位或 (this | val) 。 |
| BigInteger | xor(BigInteger val)
异或,(this ^ val) 。 |
| BigInteger | negate()
取反,返回相反数 |
| BigInteger | shiftLeft(int n)
左移n位, (this << n) 。 |
| BigInteger | shiftRight(int n)
右移n位,(this >> n) 。 |
| 比较 | |
| int | compareTo(BigInteger val)
比较,返回值:小于val = -1,等于val = 0,大于val = 1 |
| BigInteger | max(BigInteger val)
比较,返回最大数 |
| BigInteger | min(BigInteger val)
比较,返回最小数 |
| 转换 | |
| int | intValue()
将此BigInteger转换为 int 。 |
| long | longValue()
将此BigInteger转换为 long 。 |
| double | doubleValue()
将此BigInteger转换为 double 。 |
| float | floatValue()
将此BigInteger转换为 float 。 |
| byte[] | toByteArray()
将整数转换成二进制,再反码,保存到byte数组中 |
| String | toString()
返回此BigInteger的十进制字符串表示形式。 |
| String | toString(int radix)
返回给定基数中BigInteger的String表示形式。 |
| static BigInteger | valueOf(long val)
返回一个BigInteger,其值等于指定的 long 。 |
| 其它 | |
| BigInteger | andNot(BigInteger val)
返回值为 (this & ~val) 。 |
| int | bitCount()
返回与其符号位不同的BigInteger的二进制补码表示中的位数。 |
| int | bitLength()
返回此BigInteger的最小二进制补码表示中的位数, 不包括符号位。 |
| byte | byteValueExact()
将此 BigInteger转换为 byte ,检查丢失的信息。 |
| BigInteger | clearBit(int n)
返回一个BigInteger,其值等于此BigInteger,指定的位被清零。 |
| boolean | equals(Object x)
将此BigInteger与指定的对象进行比较以实现相等。 |
| BigInteger | flipBit(int n)
返回一个BigInteger,其值等于此BigInteger,指定的位被翻转。 |
| BigInteger | gcd(BigInteger val)
返回最大公约数,其值是 abs(this)和 abs(val) 。 |
| int | getLowestSetBit()
返回此BigInteger中最右(最低位)一位的索引(最右边一位右侧的零位数)。 |
| int | hashCode()
返回此BigInteger的哈希码。 |
| int | intValueExact()
将此 BigInteger转换为 int ,检查丢失的信息。 |
| boolean | isProbablePrime(int certainty)
返回 true如果这个BigInteger可能是素数, false如果它是绝对复合。 |
| long | longValueExact()
将此 BigInteger转换为 long ,检查丢失的信息。 |
| BigInteger | mod(BigInteger m)
求模,返回值为 (this mod m )。 |
| BigInteger | modInverse(BigInteger m)
返回值为 (this -1 mod m) 。 |
| BigInteger | modPow(BigInteger m)
返回值为 (thisexponent mod m)的BigInteger 。 |
| BigInteger | nextProbablePrime()
返回大于这个 BigInteger为 BigInteger的第一个整数。 |
| static BigInteger | probablePrime(int bitLength, Random rnd)
返回一个正的BigInteger,它可能是素数,具有指定的位长度。 |
| BigInteger | setBit(int n)
返回一个BigInteger,其值等于具有指定位集合的BigInteger。 |
| short | shortValueExact()
将此 BigInteger转换为 short ,检查丢失的信息。 |
| int | signum()
返回此BigInteger的signum函数。 |
| boolean | testBit(int n)
返回 true当且仅当指定的位被设置。 |
BigInteger a = new BigInteger("1234"); //构造类
BigInteger b = new BigInteger("5678");
BigInteger[] c= a.divideAndRemainder(b); //除法,返回商和余
System.out.print(商:" + c[0].toString());
System.out.println(余:" + c[1].toString());