|
Final | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.lang.Number
java.math.BigInteger
public class BigInteger
BigInteger objects represent arbitrary precision decimal integers. They contain values that cannot be changed. Thus, most operations on the BigInteger objects yield new instances of BigInteger.
| Field Summary | |
|---|---|
static BigInteger |
ONE
Constant: 1 as represented by a BigInteger. |
static BigInteger |
TEN
Constant: 10 as represented by a BigInteger. |
static BigInteger |
ZERO
Constant: 0 as represented by a BigInteger. |
| Constructor Summary | |
|---|---|
BigInteger(byte[] bytes)
Constructs a new instance of this class given an array containing bytes representing the bit pattern for the answer. |
|
BigInteger(int sign,
byte[] bytes)
Constructs a new instance of this class given an array containing bytes representing the bit pattern for the answer, and a sign flag. |
|
BigInteger(int bitLength,
int certainty,
Random rnd)
Constructs a new instance of this class of the specified length, whose content is produced by aquiring random bits from the specified random number generator. |
|
BigInteger(int bitLength,
Random rnd)
Constructs a new instance of this class of the specified length, whose content is produced by aquiring random bits from the specified random number generator. |
|
BigInteger(String val)
Constructs a new instance of this class given a string containing a representation of a decimal number. |
|
BigInteger(String val,
int radix)
Constructs a new instance of this class given a string containing digits in the specified radix. |
|
| Method Summary | |
|---|---|
BigInteger |
abs()
Answers the absolute value of the receiver |
BigInteger |
add(BigInteger val)
Answers the sum of the receiver and a BigInteger |
BigInteger |
and(BigInteger val)
Answers the bitwise AND of the receiver and the argument. |
BigInteger |
andNot(BigInteger val)
Answers the bitwise NAND of the receiver and the argument. |
int |
bitCount()
Answers the number of set bits in the receiver. |
int |
bitLength()
Answers the length in bits of the receiver. |
BigInteger |
clearBit(int n)
Unsets the specified bit in the receiver. |
int |
compareTo(BigInteger val)
Answers an integer indicating the relative positions of the receiver and the argument in the natural order of elements of the receiver's class. |
int |
compareTo(Object o)
Answers an integer indicating the relative positions of the receiver and the argument in the natural order of elements of the receiver's class. |
BigInteger |
divide(BigInteger val)
Answers the quotient of the receiver and a BigInteger. |
BigInteger[] |
divideAndRemainder(BigInteger val)
Answers the quotient and remainder of the receiver divided by a BigInteger. |
double |
doubleValue()
Answers the double value which the receiver represents |
boolean |
equals(Object o)
Compares the argument to the receiver, and answers true if they represent the same object using a class specific comparison. |
BigInteger |
flipBit(int n)
Toggles the specified bit in the receiver. |
float |
floatValue()
Answers the float value which the receiver represents |
BigInteger |
gcd(BigInteger val)
Answers the greatest common divisor of abs(this) and abs(val), zero if this==val==0 |
int |
getLowestSetBit()
Answers the index of the lowest set bit in the receiver, or -1 if no bits are set. |
int |
hashCode()
Answers an integer hash code for the receiver. |
int |
intValue()
Answers the int value which the receiver represents |
boolean |
isProbablePrime(int certainty)
Answers true if the receiver is probably prime to the given degree of certainty. |
long |
longValue()
Answers the long value which the receiver represents |
BigInteger |
max(BigInteger val)
Answers the most positive of either the receiver or the argument. |
BigInteger |
min(BigInteger val)
Answers the most negative of either the receiver or the argument. |
BigInteger |
mod(BigInteger val)
Answers the remainder of the receiver modulo a BigInteger (a positive value). |
BigInteger |
modInverse(BigInteger modulo)
Answers the inverse of the receiver modulo a BigInteger, if it exists. |
BigInteger |
modPow(BigInteger exponent,
BigInteger modulo)
Answers the receiver to the power of exponent modulo a BigInteger |
BigInteger |
multiply(BigInteger val)
Answers the product of the receiver and a BigInteger. |
BigInteger |
negate()
Answers the negative of the receiver |
BigInteger |
not()
Answers the bitwise negation of the receiver. |
BigInteger |
or(BigInteger val)
Answers the bitwise OR of the receiver and the argument. |
BigInteger |
pow(int exponent)
Answers the receiver to the power of exponent. |
BigInteger |
remainder(BigInteger val)
Answers the remainder of the receiver divided by a BigInteger |
BigInteger |
setBit(int n)
Sets the specified bit in the receiver. |
BigInteger |
shiftLeft(int shiftval)
Answers a BigInteger with the value of the reciever multiplied by 2^shiftval. |
BigInteger |
shiftRight(int shiftval)
Answers a BigInteger with the value of the reciever divided by 2^shiftval. |
int |
signum()
Answers the sign of the receiver |
BigInteger |
subtract(BigInteger val)
Answers the difference of the receiver and a BigInteger. |
boolean |
testBit(int n)
Answers true if the specified bit is set in the receiver. |
byte[] |
toByteArray()
Answers an array of bytes containing the value of the receiver in the same format used by the matching constructor. |
String |
toString()
Answers a string containing a concise, human-readable description of the receiver. |
String |
toString(int radix)
Answers a string containing a concise, human-readable description of the receiver as a sequence of digits in the specified radix. |
static BigInteger |
valueOf(long val)
Answers a BigInteger with the same value as val |
BigInteger |
xor(BigInteger val)
Answers the bitwise XOR of the receiver and the argument. |
| Methods inherited from class java.lang.Number |
|---|
byteValue, shortValue |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final BigInteger ZERO
public static final BigInteger ONE
public static final BigInteger TEN
| Constructor Detail |
|---|
public BigInteger(int bitLength,
Random rnd)
bitLength - int
the number of bits to have in the result.rnd - Random
the generator to produce the bits.public BigInteger(int bitLength,
int certainty,
Random rnd)
bitLength - int
the number of bits to have in the result.certainty - int
the degree of certainty required that the
result is prime.rnd - Random
the generator to produce the bits.public BigInteger(byte[] bytes)
bytes - byte[]
the bits of the value of the new instance.public BigInteger(int sign,
byte[] bytes)
sign - int
the sign of the result.bytes - byte[]
the bits of the value of the new instance.public BigInteger(String val)
val - String
the decimal digits of the answer.public BigInteger(String val,
int radix)
val - String
the digits of the answer.radix - int
the radix to use for conversion.| Method Detail |
|---|
public byte[] toByteArray()
public boolean isProbablePrime(int certainty)
certainty - int
the degree of certainty required.
public boolean equals(Object o)
equals in class Objecto - Object
the object to compare with this object.
true
if the object is the same as this object
false
if it is different from this object.hashCode()public int compareTo(BigInteger val)
val - BigInteger
an object to compare the receiver to
ClassCastException - if the argument can not be converted
into something comparable with the
receiver.public int compareTo(Object o)
compareTo in interface Comparableo - Object
an object to compare the receiver to
ClassCastException - if the argument can not be converted
into something comparable with the
receiver.public int intValue()
intValue in class Numberpublic long longValue()
longValue in class Numberpublic static BigInteger valueOf(long val)
val - the long value to convert to a BigInteger
public BigInteger add(BigInteger val)
val - a BigInteger to add
public BigInteger negate()
public int signum()
public BigInteger abs()
public BigInteger pow(int exponent)
exponent - the exponent
ArithmeticException - if the exponent is negative.public BigInteger modPow(BigInteger exponent,
BigInteger modulo)
exponent - the exponentmodulo - the modulo
ArithmeticException - modulo is <= 0public BigInteger gcd(BigInteger val)
val - the value with which to compute the GCD
public BigInteger modInverse(BigInteger modulo)
modulo - BigInteger
a BigInteger to divide
ArithmeticException - if modulo is <= 0, or gcd(this,modulo) != 1public int getLowestSetBit()
public BigInteger shiftRight(int shiftval)
shiftval - int
the amount to shift the receiver.
public BigInteger shiftLeft(int shiftval)
shiftval - int
the amount to shift the receiver.
public BigInteger subtract(BigInteger val)
val - BigInteger
the value to subtract
public BigInteger multiply(BigInteger val)
val - BigInteger
the value to multiply
public BigInteger divide(BigInteger val)
val - BigInteger
the value to divide
ArithmeticException - if val is zero.public BigInteger remainder(BigInteger val)
val - a BigInteger to divide
ArithmeticException - if val is zeropublic BigInteger mod(BigInteger val)
val - the value to divide
ArithmeticException - if val is zeropublic BigInteger[] divideAndRemainder(BigInteger val)
val - BigInteger
the value to divide.
ArithmeticException - if val is zero.public String toString()
toString in class Objectpublic String toString(int radix)
radix - the radix
public BigInteger max(BigInteger val)
val - BigInteger
the value to compare.
public BigInteger min(BigInteger val)
val - BigInteger
the value to compare.
public int hashCode()
true when passed to
.equals must answer the same value for this
method.
hashCode in class Objectequals(java.lang.Object)public boolean testBit(int n)
n - int the bit to check.
public BigInteger setBit(int n)
n - int
the bit to set.
public BigInteger clearBit(int n)
n - int
the bit to clear.
public BigInteger flipBit(int n)
n - int
the bit to flip.
public BigInteger and(BigInteger val)
val - BigInteger
the value to AND.
public BigInteger or(BigInteger val)
val - BigInteger
the value to OR.
public BigInteger xor(BigInteger val)
val - BigInteger
the value to XOR.
public BigInteger not()
public BigInteger andNot(BigInteger val)
val - BigInteger
the value to NAND.
public int bitLength()
public int bitCount()
public double doubleValue()
doubleValue in class Numberpublic float floatValue()
floatValue in class Number
|
Final | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||