public class BigInteger extends java.lang.Object implements Comparable
Modifier and Type | Field and Description |
---|---|
static BigInteger |
ONE
The constant one as a BigInteger.
|
static BigInteger |
TEN
The constant ten as a BigInteger.
|
static BigInteger |
ZERO
The constant zero as a BigInteger.
|
Constructor and Description |
---|
BigInteger(byte[] val) |
BigInteger(int signum,
byte[] magnitude) |
BigInteger(int bitLength,
int certainty,
Random rnd) |
BigInteger(int numBits,
Random rnd) |
BigInteger(java.lang.String val) |
BigInteger(java.lang.String s,
int radix) |
Modifier and Type | Method and Description |
---|---|
BigInteger |
abs() |
BigInteger |
add(BigInteger val) |
BigInteger |
and(BigInteger y)
Return the logical (bit-wise) "and" of two BigIntegers.
|
BigInteger |
andNot(BigInteger val) |
int |
bitCount()
Count one bits in a BigInteger.
|
int |
bitLength()
Calculates ceiling(log2(this < 0 ? -this : this+1)) See Common Lisp: the Language, 2nd ed, p.
|
BigInteger |
clearBit(int n) |
int |
compareTo(BigInteger val) |
int |
compareTo(java.lang.Object other)
Must return > 0 if this object is greater than the other one, < 0 if its smaller, and 0 if they are equal.
|
BigInteger |
divide(BigInteger val) |
BigInteger[] |
divideAndRemainder(BigInteger val) |
double |
doubleValue() |
boolean |
equals(java.lang.Object obj) |
BigInteger |
flipBit(int n) |
BigInteger |
gcd(BigInteger y) |
int |
getLowestSetBit() |
int |
hashCode() |
int |
intValue() |
boolean |
isProbablePrime(int certainty)
Returns
true if this BigInteger is probably prime, false if it's definitely composite. |
long |
longValue() |
BigInteger |
max(BigInteger val) |
BigInteger |
min(BigInteger val) |
BigInteger |
mod(BigInteger m) |
BigInteger |
modInverse(BigInteger y) |
BigInteger |
modPow(BigInteger exponent,
BigInteger m) |
BigInteger |
multiply(BigInteger y) |
BigInteger |
negate() |
BigInteger |
not()
Return the logical (bit-wise) negation of a BigInteger.
|
BigInteger |
or(BigInteger y)
Return the logical (bit-wise) "(inclusive) or" of two BigIntegers.
|
BigInteger |
pow(int exponent)
Calculate the integral power of a BigInteger.
|
static BigInteger |
probablePrime(int bitLength,
Random rnd)
Return a BigInteger that is bitLength bits long with a probability < 2^-100 of being composite.
|
BigInteger |
remainder(BigInteger val) |
BigInteger |
setBit(int n) |
BigInteger |
shiftLeft(int n) |
BigInteger |
shiftRight(int n) |
int |
signum() |
BigInteger |
subtract(BigInteger val) |
boolean |
testBit(int n) |
byte[] |
toByteArray() |
java.lang.String |
toString() |
java.lang.String |
toString(int radix) |
void |
toStringBuffer(int radix,
java.lang.StringBuffer sb) |
static BigInteger |
valueOf(long val)
Return a (possibly-shared) BigInteger with a given long value.
|
BigInteger |
xor(BigInteger y)
Return the logical (bit-wise) "exclusive or" of two BigIntegers.
|
public static final BigInteger ZERO
public static final BigInteger ONE
public static final BigInteger TEN
public BigInteger(java.lang.String s, int radix) throws InvalidNumberException
InvalidNumberException
public BigInteger(java.lang.String val) throws InvalidNumberException
InvalidNumberException
public BigInteger(byte[] val) throws InvalidNumberException
InvalidNumberException
public BigInteger(int signum, byte[] magnitude) throws InvalidNumberException
InvalidNumberException
public BigInteger(int numBits, Random rnd)
public BigInteger(int bitLength, int certainty, Random rnd)
public static BigInteger probablePrime(int bitLength, Random rnd)
bitLength
- length in bits of resulting numberrnd
- random number generator to usejava.lang.ArithmeticException
- if bitLength < 2public static BigInteger valueOf(long val)
public int signum()
public int compareTo(BigInteger val)
public BigInteger min(BigInteger val)
public BigInteger max(BigInteger val)
public BigInteger add(BigInteger val)
public BigInteger subtract(BigInteger val)
public BigInteger multiply(BigInteger y)
public BigInteger divide(BigInteger val)
public BigInteger remainder(BigInteger val)
public BigInteger[] divideAndRemainder(BigInteger val)
public BigInteger mod(BigInteger m)
public BigInteger pow(int exponent)
exponent
- the exponent (must be non-negative)public BigInteger modInverse(BigInteger y)
public BigInteger modPow(BigInteger exponent, BigInteger m)
public BigInteger gcd(BigInteger y)
public boolean isProbablePrime(int certainty)
Returns true
if this BigInteger is probably prime, false
if it's definitely composite.
If certainty
is <= 0
, true
is returned.
certainty
- a measure of the uncertainty that the caller is willing to tolerate: if the call returns
true
the probability that this BigInteger is prime exceeds
(1 - 1/2certainty)
. The execution time of this method is proportional to the
value of this parameter.true
if this BigInteger is probably prime, false
if it's definitely composite.public BigInteger shiftLeft(int n)
public BigInteger shiftRight(int n)
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toString(int radix)
public void toStringBuffer(int radix, java.lang.StringBuffer sb)
public int intValue()
public long longValue()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public double doubleValue()
public BigInteger abs()
public BigInteger negate()
public int bitLength()
public byte[] toByteArray()
public BigInteger and(BigInteger y)
public BigInteger or(BigInteger y)
public BigInteger xor(BigInteger y)
public BigInteger not()
public BigInteger andNot(BigInteger val)
public BigInteger clearBit(int n)
public BigInteger setBit(int n)
public boolean testBit(int n)
public BigInteger flipBit(int n)
public int getLowestSetBit()
public int bitCount()
public int compareTo(java.lang.Object other) throws java.lang.ClassCastException
Comparable
compareTo
in interface Comparable
java.lang.ClassCastException