Class Mpz
- All Implemented Interfaces:
Serializable,Cloneable,Comparable<Mpz>
- Direct Known Subclasses:
MpzRef
This class wraps mpz_t GMP objects.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThis value can be returned by bit-searching or bit-counting operations. -
Constructor Summary
ConstructorsConstructorDescriptionMpz()Constructs an uninitialized number.Mpz(double d) Constructs a number initialized with a double.Mpz(int i) Constructs a number initialized with an integer.Mpz(int sign, byte[] mag) Constructs a number from a unsigned stored in a big-endian byte array and a sign.Constructs a copy of its argument.Constructs a number initialized from a string representation.Constructs a number initialized from a string representation in base b.Mpz(BigInteger b) Constructs a number initialized from a Java big integer. -
Method Summary
Modifier and TypeMethodDescriptionvoidabs()Replaces this with |this|.voidStores |arg| into this.voidadd(int arg) Adds arg to this.voidAdds arg to this.voidStores arg1+arg2 into this.voidStores arg1+arg2 into this.voidStores this+arg1*arg2 into this.voidStores this+arg1*arg2 into this.voidStores the bitwise and of this and op into this.voidStores the bitwise and of op1 and op2 into this.Returns this as a Java big integer.voidbin(int n, int k) Stores into this the binomial coefficient (n k).voidStores into this the binomial coefficient (n k).byte[]Returns the magnitude of this.intcdivQ(int d) Divides this by d, rounds towards +oo, and returns the remainder.voidDivides this by d and rounds towards +oo.intStores the quotient of n/d rounded towards +oo into this, and returns the remainder.voidStores the quotient of n/d rounded towards +oo into this.voidStores the quotient of n/(2^d) rounded towards +oo into this.intStores the quotient of n/d rounded towards +oo into this, the remainder into r, and returns the remainder.voidStores the quotient of n/d rounded towards +oo into this and the remainder into r.intcdivR(int d) Returns the remainder of of this/d rounded towards +oo.intStores the remainder of n/d rounded towards +oo into this, and returns the remainder.voidStores the remainder of n/d rounded towards +oo into this.voidStores the remainder of n/(2^d) rounded towards +oo into this.clone()Creates a new Mpz initialized with the value of this.voidclrBit(int pos) Sets the pos-th bit to 0 in this.intcmp(double op) Returns a positive, null, or negative number when this is respectively strictly greater, equal, or strictly smaller than op.intcmp(int op) Returns a positive, null, or negative number when this is respectively strictly greater, equal, or strictly smaller than op.intReturns a positive, null, or negative number when this is respectively strictly greater, equal, or strictly smaller than op.intcmpAbs(double op) Returns a positive, null, or negative number when |this| is respectively strictly greater, equal, or strictly smaller than |op|.intcmpAbs(int op) Returns a positive, null, or negative number when |this| is respectively strictly greater, equal, or strictly smaller than |op|.intReturns a positive, null, or negative number when |this| is respectively strictly greater, equal, or strictly smaller than |op|.intCompare the value of this and x.voiddivExact(int d) Divides this by d, assuming that d divides this. d must be positive.voidDivides this by d, assuming that d divides this.voidStores n/d into this, assuming that d divides n. d must be positive.voidStores n/d into this, assuming that d divides n.doubledoubleExponentValue(int[] r) Converts the integer to a mantissa and exponent.doubleReturns this as a double.booleanWhether x is a Mpz and has the same value as this.voidfac(int op) Stores op!intfdivQ(int d) Divides this by d, rounds towards -oo, and returns the remainder.voidDivides this by d and rounds towards -oo.intStores the quotient of n/d rounded towards -oo into this, and returns the remainder.voidStores the quotient of n/d rounded towards -oo into this.voidStores the quotient of n/(2^d) rounded towards -oo into this.intStores the quotient of n/d rounded towards -oo into this, the remainder into r, and returns the remainder.voidStores the quotient of n/d rounded towards -oo into this and the remainder into r.intfdivR(int d) Returns the remainder of of this/d rounded towards -oo.intStores the remainder of n/d rounded towards -oo into this, and returns the remainder.voidStores the remainder of n/d rounded towards -oo into this.voidStores the remainder of n/(2^d) rounded towards -oo into this.voidfib(int n) Stores into this the n-th Fibonacci number.voidStores into this the n-th Fibonacci number, and into r the n-1-th Fibonacci number.booleanfitsInt()Whether this can fit in an int.intReturns the greatest common divisor of op1 and op2.voidStores into this the greatest common divisor of op1 and op2.voidStores the greatest common divisor of op1 and op2 into this.intReturns the Hamming distance between this and op.inthashCode()Returns a hash of the value of this.intintValue()Returns this as an integer.booleanStores the inverse of op1 modulo op2 into this.booleanisCongruent(int c, int d) Returns true if this equals c modulo d.booleanisCongruent(Mpz c, Mpz d) Returns true if this equals c modulo d.booleanisCongruent2exp(Mpz c, int d) Returns true if this equals c modulo 2^d.booleanisDivisible(int d) Returns true if d divides this.booleanisDivisible(Mpz d) Returns true if d divides this.booleanisDivisible2exp(int d) Returns true if 2^d divides this.booleanWhether this and x have the same value.booleanisEven()Whether this is even.booleanisOdd()Whether this is odd.booleanReturns true if this has the form a^b for some a and b > 1.booleanReturns true if this has the form a^2 for some a.booleanWhether this and x have the same address in memory.intisProbabPrime(int r) Returns 2 if this is definitely prime, 1 if it is probably prime, and 0 if it is definitely composite.static intReturns the Jacobi symbol of a and b.static intReturns the Jacobi symbol with the Kronecker extension.static intReturns the Jacobi symbol with the Kronecker extension.static intReturns the Jacobi symbol with the Kronecker extension.voidStores into this the least common multiple of op1 and op2.voidStores into this the least common multiple of op1 and op2.static intReturns the Legendre symbol.voidlucnum(int n) Stores into this the n-th Lucas number.voidStores into this the n-th Lucas number, and into r the n-1-th Lucas number.intmod(int d) Replaces this with this mod |d|.voidReplaces this with this mod |d|.intStores n mod |d| into this and returns it.voidStores n mod |d| into this.voidmul(int arg) Multiplies this by arg.voidMultiplies this by arg.voidStores arg1*arg2 into this.voidStores arg1*arg2 into this.voidmul2exp(int arg) Multiplies this by 2^arg.voidStores arg1*2^arg2 into this.voidneg()Replaces this with -this.voidStores -arg into this.voidStores into this the next prime greater than op.voidnot()Stores the bitwise complement of this into this.voidStores the bitwise complement of op into this.voidnotBit(int pos) Inverts the pos-th bit in this.voidStores the bitwise or of this and op into this.voidStores the bitwise or of op1 and op2 into this.intpopCount()Returns the number of bits set to 1 in this.voidpow(int e) Takes the e-th power of this.voidpow(int b, int e) Stores b^e into this.voidStores b^e into this.voidStores b^e mod m into this.voidStores b^e mod m into this.voidStores into this a uniformly distributed random number in 0..n-1.voidrandomBits(RandState r, int n) Stores into this a uniformly distributed random number with n bits (i.e., in 0..2^n-1).intRemoves from this all occurrences of factor f.intStores into this op with all occurrences of factor f removed.booleanroot(int n) Takes the n-th root of this, truncated.booleanStores the n-th root of op into this, truncated.voidStores the n-th root of op into this, truncated, and the remainder op-this^n into r.voidrRandomBits(RandState r, int n) Stores into this a random number with n bits, and long strings of zeros and ones in its binary representation.intscan0(int pos) Returns the position of the first bit set to 0 at or after position pos.intscan1(int pos) Returns the position of the first bit set to 1 at or after position pos.voidset(double d) Sets this to a double.voidset(int i) Sets this to an integer.voidset(int sign, byte[] mag) Sets the value of this given a magnitude and a sign.voidCopies the argument into this.voidSets this to the String s.voidSets this to the String s expressed in base b.voidset(BigInteger b) Sets this to a Java big integer.voidsetBit(int pos) Sets the pos-th bit to 1 in this.intsgn()Returns +1, 0, or -1 when this is respectively strictly positive, null, or strictly negative.intsize()Returns the size (in GMP limbs) of the internal representation of this.intsizeInBase(int b) Returns the number of digits necessary to represent |this| in base b.voidsqrt()Takes the truncated square root of this.voidStores the truncated square root of op into this.voidStores the square root of op into this, truncated, and the remainder op-this^2 into r.voidsub(int arg) Subtracts arg from this.voidStores arg1-arg2 into this.voidSubtracts arg from this.voidStores arg1-arg2 into this.voidStores arg1-arg2 into this.voidStores this-arg1*arg2 into this.voidStores this-arg1*arg2 into this.voidsubRev(int arg) Replaces this with arg-this.inttdivQ(int d) Divides this by d, rounds towards 0, and returns the remainder.voidDivides this by d and rounds towards 0.intStores the quotient of n/d rounded towards 0 into this, and returns the remainder.voidStores the quotient of n/d rounded towards 0 into this.voidStores the quotient of n/(2^d) rounded towards 0 into this.intStores the quotient of n/d rounded towards 0 into this, the remainder into r, and returns the remainder.voidStores the quotient of n/d rounded towards 0 into this and the remainder into r.inttdivR(int d) Returns the remainder of of this/d rounded towards 0.intStores the remainder of n/d rounded towards 0 into this, and returns the remainder.voidStores the remainder of n/d rounded towards 0 into this.voidStores the remainder of n/(2^d) rounded towards 0 into this.toString()Returns a String representation this in base 10.toString(int b) Returns a String representation of this in base b.booleantstBit(int pos) Returns true if the pos-th bit in this is 1.voidStores the bitwise xor of this and op into this.voidStores the bitwise xor of op1 and op2 into this.
-
Field Details
-
infinite
public static final int infiniteThis value can be returned by bit-searching or bit-counting operations.- See Also:
-
-
Constructor Details
-
Mpz
public Mpz()Constructs an uninitialized number. -
Mpz
Constructs a copy of its argument. -
Mpz
public Mpz(int i) Constructs a number initialized with an integer. -
Mpz
public Mpz(double d) Constructs a number initialized with a double.The value is truncated to an integer.
-
Mpz
Constructs a number initialized from a Java big integer. -
Mpz
Constructs a number initialized from a string representation in base b.- Parameters:
b- must be either 0, or between 2 and 62. When b is 0, the leading characters are used to determine the base (0x and 0X for hexadecimal, 0b and 0B for binary, 0 for octal, decimal otherwise).
-
Mpz
Constructs a number initialized from a string representation.The leading characters are used to determine whether base: 0x and 0X for hexadecimal, 0b and 0B for binary, 0 for octal, and decimal otherwise.
-
Mpz
public Mpz(int sign, byte[] mag) Constructs a number from a unsigned stored in a big-endian byte array and a sign.
-
-
Method Details
-
set
public void set(int sign, byte[] mag) Sets the value of this given a magnitude and a sign.Used during deserialization.
mag is the absolute value encoded in a byte array in big endian order.
-
byteArrayValue
public byte[] byteArrayValue()Returns the magnitude of this.User during serialization.
The magnitude is the absolute value, and it is returned as a byte array stored in big-endian order.
-
clone
Creates a new Mpz initialized with the value of this.- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-
set
Copies the argument into this. -
set
public void set(int i) Sets this to an integer. -
set
public void set(double d) Sets this to a double.The value is truncated.
-
set
Sets this to a Java big integer. -
set
Sets this to the String s expressed in base b.- See Also:
-
set
Sets this to the String s.- See Also:
-
intValue
public int intValue()Returns this as an integer.The result is truncated if it does not fit in an integer.
- See Also:
-
doubleValue
public double doubleValue()Returns this as a double.If this cannot be represented as a double, the result is truncated.
Overflows cause infinities to be returned.
-
doubleExponentValue
public double doubleExponentValue(int[] r) Converts the integer to a mantissa and exponent.The mantissa m returned is such that 0.5 <= |m| < 1, truncated to fit double.
The exponent is stored into r[0].
-
bigIntegerValue
Returns this as a Java big integer. -
toString
Returns a String representation of this in base b.- Parameters:
b- must be between 2 and 62.
-
toString
Returns a String representation this in base 10. -
add
Stores arg1+arg2 into this. -
add
Stores arg1+arg2 into this. -
add
Adds arg to this. -
add
public void add(int arg) Adds arg to this. -
sub
Stores arg1-arg2 into this. -
sub
Stores arg1-arg2 into this. -
sub
Stores arg1-arg2 into this. -
sub
Subtracts arg from this. -
sub
public void sub(int arg) Subtracts arg from this. -
subRev
public void subRev(int arg) Replaces this with arg-this. -
mul
Stores arg1*arg2 into this. -
mul
Stores arg1*arg2 into this. -
mul
Multiplies this by arg. -
mul
public void mul(int arg) Multiplies this by arg. -
addMul
Stores this+arg1*arg2 into this. -
addMul
Stores this+arg1*arg2 into this. -
subMul
Stores this-arg1*arg2 into this. -
subMul
Stores this-arg1*arg2 into this. -
mul2exp
Stores arg1*2^arg2 into this.arg2 must be positive.
-
mul2exp
public void mul2exp(int arg) Multiplies this by 2^arg.arg must be positive.
-
neg
Stores -arg into this. -
neg
public void neg()Replaces this with -this. -
abs
Stores |arg| into this. -
abs
public void abs()Replaces this with |this|. -
cdivQ
Stores the quotient of n/d rounded towards +oo into this.- Throws:
ArithmeticException
-
cdivQ
Divides this by d and rounds towards +oo.- Throws:
ArithmeticException
-
cdivR
Stores the remainder of n/d rounded towards +oo into this.- Throws:
ArithmeticException
-
cdivQR
Stores the quotient of n/d rounded towards +oo into this and the remainder into r.- Throws:
ArithmeticException
-
cdivQ
Stores the quotient of n/d rounded towards +oo into this, and returns the remainder.d must be positive.
- Throws:
ArithmeticException
-
cdivQ
Divides this by d, rounds towards +oo, and returns the remainder.d must be positive.
- Throws:
ArithmeticException
-
cdivR
Stores the remainder of n/d rounded towards +oo into this, and returns the remainder.d must be positive.
- Throws:
ArithmeticException
-
cdivQR
Stores the quotient of n/d rounded towards +oo into this, the remainder into r, and returns the remainder.d must be positive.
- Throws:
ArithmeticException
-
cdivR
Returns the remainder of of this/d rounded towards +oo.this is unchanged.
d must be positive.
- Throws:
ArithmeticException
-
cdivQ2exp
Stores the quotient of n/(2^d) rounded towards +oo into this.d must be positive.
- Throws:
ArithmeticException
-
cdivR2exp
Stores the remainder of n/(2^d) rounded towards +oo into this.d must be positive.
- Throws:
ArithmeticException
-
fdivQ
Stores the quotient of n/d rounded towards -oo into this.- Throws:
ArithmeticException
-
fdivQ
Divides this by d and rounds towards -oo.- Throws:
ArithmeticException
-
fdivR
Stores the remainder of n/d rounded towards -oo into this.- Throws:
ArithmeticException
-
fdivQR
Stores the quotient of n/d rounded towards -oo into this and the remainder into r.- Throws:
ArithmeticException
-
fdivQ
Stores the quotient of n/d rounded towards -oo into this, and returns the remainder.d must be positive.
- Throws:
ArithmeticException
-
fdivQ
Divides this by d, rounds towards -oo, and returns the remainder.d must be positive.
- Throws:
ArithmeticException
-
fdivR
Stores the remainder of n/d rounded towards -oo into this, and returns the remainder.d must be positive.
- Throws:
ArithmeticException
-
fdivQR
Stores the quotient of n/d rounded towards -oo into this, the remainder into r, and returns the remainder.d must be positive.
- Throws:
ArithmeticException
-
fdivR
Returns the remainder of of this/d rounded towards -oo.this is unchanged.
d must be positive.
- Throws:
ArithmeticException
-
fdivQ2exp
Stores the quotient of n/(2^d) rounded towards -oo into this.- Throws:
ArithmeticException
-
fdivR2exp
Stores the remainder of n/(2^d) rounded towards -oo into this.d must be positive.
- Throws:
ArithmeticException
-
tdivQ
Stores the quotient of n/d rounded towards 0 into this.- Throws:
ArithmeticException
-
tdivQ
Divides this by d and rounds towards 0.- Throws:
ArithmeticException
-
tdivR
Stores the remainder of n/d rounded towards 0 into this.- Throws:
ArithmeticException
-
tdivQR
Stores the quotient of n/d rounded towards 0 into this and the remainder into r.- Throws:
ArithmeticException
-
tdivQ
Stores the quotient of n/d rounded towards 0 into this, and returns the remainder.d must be positive.
- Throws:
ArithmeticException
-
tdivQ
Divides this by d, rounds towards 0, and returns the remainder.d must be positive.
- Throws:
ArithmeticException
-
tdivR
Stores the remainder of n/d rounded towards 0 into this, and returns the remainder.d must be positive.
- Throws:
ArithmeticException
-
tdivQR
Stores the quotient of n/d rounded towards 0 into this, the remainder into r, and returns the remainder.d must be positive.
- Throws:
ArithmeticException
-
tdivR
Returns the remainder of of this/d rounded towards 0.this is unchanged.
d must be positive.
- Throws:
ArithmeticException
-
tdivQ2exp
Stores the quotient of n/(2^d) rounded towards 0 into this.d must be positive.
- Throws:
ArithmeticException
-
tdivR2exp
Stores the remainder of n/(2^d) rounded towards 0 into this.d must be positive.
- Throws:
ArithmeticException
-
mod
Stores n mod |d| into this.- Throws:
ArithmeticException
-
mod
Replaces this with this mod |d|.- Throws:
ArithmeticException
-
mod
Stores n mod |d| into this and returns it.- Throws:
ArithmeticException
-
mod
Replaces this with this mod |d|.- Throws:
ArithmeticException
-
divExact
Stores n/d into this, assuming that d divides n.- Throws:
ArithmeticException
-
divExact
Divides this by d, assuming that d divides this.- Throws:
ArithmeticException
-
divExact
Stores n/d into this, assuming that d divides n. d must be positive.- Throws:
ArithmeticException
-
divExact
Divides this by d, assuming that d divides this. d must be positive.- Throws:
ArithmeticException
-
isDivisible
Returns true if d divides this.Only 0 is divisible by 0.
-
isDivisible
public boolean isDivisible(int d) Returns true if d divides this.d must be positive.
Only 0 is divisible by 0.
-
isDivisible2exp
public boolean isDivisible2exp(int d) Returns true if 2^d divides this.d must be positive.
-
isCongruent
Returns true if this equals c modulo d.When d=0, returns true if this equals c.
-
isCongruent
public boolean isCongruent(int c, int d) Returns true if this equals c modulo d.d must be positive.
When d=0, returns true if this equals c.
-
isCongruent2exp
Returns true if this equals c modulo 2^d.d must be positive.
-
pow
Stores b^e mod m into this.Throws an ArithmeticException if e < 0 and b has no inverse modulo m.
- Throws:
ArithmeticException
-
pow
Stores b^e mod m into this.e must be positive.
- Throws:
ArithmeticException
-
pow
Stores b^e into this.e must be positive.
0^0 is 1.
-
pow
public void pow(int e) Takes the e-th power of this.e must be positive.
0^0 is 1.
-
pow
public void pow(int b, int e) Stores b^e into this.b and e must be positive.
0^0 is 1.
-
root
Stores the n-th root of op into this, truncated.Returns true if the computation was exact.
n must be positive.
-
root
public boolean root(int n) Takes the n-th root of this, truncated.Returns true if the computation was exact.
n must be positive.
-
root
Stores the n-th root of op into this, truncated, and the remainder op-this^n into r.n must be positive.
-
sqrt
Stores the truncated square root of op into this. -
sqrt
public void sqrt()Takes the truncated square root of this. -
sqrt
Stores the square root of op into this, truncated, and the remainder op-this^2 into r. -
isPerfectPower
public boolean isPerfectPower()Returns true if this has the form a^b for some a and b > 1.0 and 1 are perfect powers.
-
isPerfectSquare
public boolean isPerfectSquare()Returns true if this has the form a^2 for some a.0 and 1 are perfect squares.
-
isProbabPrime
public int isProbabPrime(int r) Returns 2 if this is definitely prime, 1 if it is probably prime, and 0 if it is definitely composite.r is the number of tests; high numbers increasing the certainty. A value between 5 and 10 is reasonable.
-
nextPrime
Stores into this the next prime greater than op.This uses a probabilistic algorithm so that the chance of getting a composite are non-null but extremely small.
-
gcd
Stores into this the greatest common divisor of op1 and op2.The result is always positive, even for negative inputs.
-
gcd
Returns the greatest common divisor of op1 and op2.this is unchanged.
op2 must be strictly positive.
-
gcd
Stores the greatest common divisor of op1 and op2 into this.Sets s and t to values such that s*op1+t*op2 = gcd and |s| <= |op2|, |t| <= |op1|.
-
lcm
Stores into this the least common multiple of op1 and op2. -
lcm
Stores into this the least common multiple of op1 and op2.op2 must be positive.
-
invert
Stores the inverse of op1 modulo op2 into this.Returns true if this inverse exists. Otherwise, returns false; this is undefined.
-
jacobi
Returns the Jacobi symbol of a and b.b must be odd.
-
legendre
Returns the Legendre symbol.p must be an odd positive prime.
-
kronecker
Returns the Jacobi symbol with the Kronecker extension. -
kronecker
Returns the Jacobi symbol with the Kronecker extension. -
kronecker
Returns the Jacobi symbol with the Kronecker extension. -
remove
Stores into this op with all occurrences of factor f removed.Returns the number of removed factors.
-
remove
Removes from this all occurrences of factor f.Returns the number of removed factors.
-
fac
public void fac(int op) Stores op! into this.op must be positive.
-
bin
Stores into this the binomial coefficient (n k).k must be positive.
-
bin
public void bin(int n, int k) Stores into this the binomial coefficient (n k).n and k must be positive.
-
fib
public void fib(int n) Stores into this the n-th Fibonacci number.n must be positive.
-
fib
Stores into this the n-th Fibonacci number, and into r the n-1-th Fibonacci number.n must be positive.
-
lucnum
public void lucnum(int n) Stores into this the n-th Lucas number.n must be positive.
-
lucnum
Stores into this the n-th Lucas number, and into r the n-1-th Lucas number.n must be positive.
-
cmp
Returns a positive, null, or negative number when this is respectively strictly greater, equal, or strictly smaller than op. -
cmp
public int cmp(int op) Returns a positive, null, or negative number when this is respectively strictly greater, equal, or strictly smaller than op. -
cmp
public int cmp(double op) Returns a positive, null, or negative number when this is respectively strictly greater, equal, or strictly smaller than op. -
cmpAbs
Returns a positive, null, or negative number when |this| is respectively strictly greater, equal, or strictly smaller than |op|. -
cmpAbs
public int cmpAbs(int op) Returns a positive, null, or negative number when |this| is respectively strictly greater, equal, or strictly smaller than |op|. -
cmpAbs
public int cmpAbs(double op) Returns a positive, null, or negative number when |this| is respectively strictly greater, equal, or strictly smaller than |op|. -
sgn
public int sgn()Returns +1, 0, or -1 when this is respectively strictly positive, null, or strictly negative. -
isEqual
Whether this and x have the same value. -
equals
Whether x is a Mpz and has the same value as this. -
compareTo
Compare the value of this and x.- Specified by:
compareToin interfaceComparable<Mpz>
-
hashCode
public int hashCode()Returns a hash of the value of this. -
isPhysicalEqual
Whether this and x have the same address in memory. -
and
Stores the bitwise and of op1 and op2 into this. -
and
Stores the bitwise and of this and op into this. -
or
Stores the bitwise or of op1 and op2 into this. -
or
Stores the bitwise or of this and op into this. -
xor
Stores the bitwise xor of op1 and op2 into this. -
xor
Stores the bitwise xor of this and op into this. -
not
Stores the bitwise complement of op into this. -
not
public void not()Stores the bitwise complement of this into this. -
popCount
public int popCount()Returns the number of bits set to 1 in this.Returns
infiniteif this is negative. -
hamDist
Returns the Hamming distance between this and op.Returns
infiniteif this and op have different signs. -
scan0
public int scan0(int pos) Returns the position of the first bit set to 0 at or after position pos.pos must be positive.
May return
infinite, if this is negative. -
scan1
public int scan1(int pos) Returns the position of the first bit set to 1 at or after position pos.pos must be positive.
May return
infinite, if this is positive. -
setBit
public void setBit(int pos) Sets the pos-th bit to 1 in this.pos must be positive.
-
clrBit
public void clrBit(int pos) Sets the pos-th bit to 0 in this.pos must be positive.
-
notBit
public void notBit(int pos) Inverts the pos-th bit in this.pos must be positive.
-
tstBit
public boolean tstBit(int pos) Returns true if the pos-th bit in this is 1.pos must be positive.
-
fitsInt
public boolean fitsInt()Whether this can fit in an int. -
isOdd
public boolean isOdd()Whether this is odd. -
isEven
public boolean isEven()Whether this is even. -
sizeInBase
public int sizeInBase(int b) Returns the number of digits necessary to represent |this| in base b. -
size
public int size()Returns the size (in GMP limbs) of the internal representation of this. -
randomBits
Stores into this a uniformly distributed random number with n bits (i.e., in 0..2^n-1).n must be positive.
-
random
Stores into this a uniformly distributed random number in 0..n-1. -
rRandomBits
Stores into this a random number with n bits, and long strings of zeros and ones in its binary representation.Useful to trigger corner-case bugs when testing.
-