java.math

Class BigInteger

public class BigInteger extends Number implements Comparable<BigInteger>

Written using on-line Java Platform 1.2 API Specification, as well as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998) and "Applied Cryptography, Second Edition" by Bruce Schneier (Wiley, 1996). Based primarily on IntNum.java BitOps.java by Per Bothner (per@bothner.com) (found in Kawa 1.6.62).

UNKNOWN: December 20, 1999. believed complete and correct.

Field Summary
static BigIntegerONE
The constant one as a BigInteger.
static BigIntegerTEN
The constant ten as a BigInteger.
static BigIntegerZERO
The constant zero as a BigInteger.
Constructor Summary
BigInteger(String val, int radix)
BigInteger(String val)
BigInteger(byte[] val)
BigInteger(int signum, byte[] magnitude)
BigInteger(int numBits, Random rnd)
BigInteger(int bitLength, int certainty, Random rnd)
Method Summary
BigIntegerabs()
BigIntegeradd(BigInteger val)
BigIntegerand(BigInteger y)
Return the logical (bit-wise) "and" of two BigIntegers.
BigIntegerandNot(BigInteger val)
intbitCount()
Count one bits in a BigInteger.
intbitLength()
Calculates ceiling(log2(this < 0 ?
BigIntegerclearBit(int n)
intcompareTo(BigInteger val)
BigIntegerdivide(BigInteger val)
BigInteger[]divideAndRemainder(BigInteger val)
doubledoubleValue()
booleanequals(Object obj)
BigIntegerflipBit(int n)
floatfloatValue()
BigIntegergcd(BigInteger y)
intgetLowestSetBit()
inthashCode()
intintValue()
booleanisProbablePrime(int certainty)

Returns true if this BigInteger is probably prime, false if it's definitely composite.

longlongValue()
BigIntegermax(BigInteger val)
BigIntegermin(BigInteger val)
BigIntegermod(BigInteger m)
BigIntegermodInverse(BigInteger y)
BigIntegermodPow(BigInteger exponent, BigInteger m)
BigIntegermultiply(BigInteger y)
BigIntegernegate()
BigIntegernot()
Return the logical (bit-wise) negation of a BigInteger.
BigIntegeror(BigInteger y)
Return the logical (bit-wise) "(inclusive) or" of two BigIntegers.
BigIntegerpow(int exponent)
Calculate the integral power of a BigInteger.
static BigIntegerprobablePrime(int bitLength, Random rnd)
Return a BigInteger that is bitLength bits long with a probability < 2^-100 of being composite.
BigIntegerremainder(BigInteger val)
BigIntegersetBit(int n)
BigIntegershiftLeft(int n)
BigIntegershiftRight(int n)
intsignum()
BigIntegersubtract(BigInteger val)
booleantestBit(int n)
byte[]toByteArray()
StringtoString()
StringtoString(int radix)
static BigIntegervalueOf(long val)
Return a (possibly-shared) BigInteger with a given long value.
BigIntegerxor(BigInteger y)
Return the logical (bit-wise) "exclusive or" of two BigIntegers.

Field Detail

ONE

public static final BigInteger ONE
The constant one as a BigInteger.

Since: 1.2

TEN

public static final BigInteger TEN
The constant ten as a BigInteger.

Since: 1.5

ZERO

public static final BigInteger ZERO
The constant zero as a BigInteger.

Since: 1.2

Constructor Detail

BigInteger

public BigInteger(String val, int radix)

BigInteger

public BigInteger(String val)

BigInteger

public BigInteger(byte[] val)

BigInteger

public BigInteger(int signum, byte[] magnitude)

BigInteger

public BigInteger(int numBits, Random rnd)

BigInteger

public BigInteger(int bitLength, int certainty, Random rnd)

Method Detail

abs

public BigInteger abs()

add

public BigInteger add(BigInteger val)

and

public BigInteger and(BigInteger y)
Return the logical (bit-wise) "and" of two BigIntegers.

andNot

public BigInteger andNot(BigInteger val)

bitCount

public int bitCount()
Count one bits in a BigInteger. If argument is negative, count zero bits instead.

bitLength

public int bitLength()
Calculates ceiling(log2(this < 0 ? -this : this+1)) See Common Lisp: the Language, 2nd ed, p. 361.

clearBit

public BigInteger clearBit(int n)

compareTo

public int compareTo(BigInteger val)

Since: 1.2

divide

public BigInteger divide(BigInteger val)

divideAndRemainder

public BigInteger[] divideAndRemainder(BigInteger val)

doubleValue

public double doubleValue()

equals

public boolean equals(Object obj)

flipBit

public BigInteger flipBit(int n)

floatValue

public float floatValue()

gcd

public BigInteger gcd(BigInteger y)

getLowestSetBit

public int getLowestSetBit()

hashCode

public int hashCode()

intValue

public int intValue()

isProbablePrime

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.

Parameters: 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.

Returns: true if this BigInteger is probably prime, false if it's definitely composite.

longValue

public long longValue()

max

public BigInteger max(BigInteger val)

min

public BigInteger min(BigInteger val)

mod

public BigInteger mod(BigInteger m)

modInverse

public BigInteger modInverse(BigInteger y)

modPow

public BigInteger modPow(BigInteger exponent, BigInteger m)

multiply

public BigInteger multiply(BigInteger y)

negate

public BigInteger negate()

not

public BigInteger not()
Return the logical (bit-wise) negation of a BigInteger.

or

public BigInteger or(BigInteger y)
Return the logical (bit-wise) "(inclusive) or" of two BigIntegers.

pow

public BigInteger pow(int exponent)
Calculate the integral power of a BigInteger.

Parameters: exponent the exponent (must be non-negative)

probablePrime

public static BigInteger probablePrime(int bitLength, Random rnd)
Return a BigInteger that is bitLength bits long with a probability < 2^-100 of being composite.

Parameters: bitLength length in bits of resulting number rnd random number generator to use

Throws: ArithmeticException if bitLength < 2

Since: 1.4

remainder

public BigInteger remainder(BigInteger val)

setBit

public BigInteger setBit(int n)

shiftLeft

public BigInteger shiftLeft(int n)

shiftRight

public BigInteger shiftRight(int n)

signum

public int signum()

subtract

public BigInteger subtract(BigInteger val)

testBit

public boolean testBit(int n)

toByteArray

public byte[] toByteArray()

toString

public String toString()

toString

public String toString(int radix)

valueOf

public static BigInteger valueOf(long val)
Return a (possibly-shared) BigInteger with a given long value.

xor

public BigInteger xor(BigInteger y)
Return the logical (bit-wise) "exclusive or" of two BigIntegers.