|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.plumtree.openfoundation.util.XPBigInteger
public class XPBigInteger
XPBigInteger is an XP implementation of BigInteger based off of opensource code from codeproject.com.
Field Summary | |
---|---|
static int |
maxLength
maximum length of the BigInteger in int (4 bytes) change this to suit the required level of precision. |
static XPBigInteger |
ONE
BigInteger Representation of One value. |
static XPBigInteger |
ZERO
BigInteger Representation of Zero value. |
Constructor Summary | |
---|---|
XPBigInteger(byte[] inData)
Translates a byte array containing the binary representation of an XPBigInteger into an XPBigInteger. |
|
XPBigInteger(int signum,
byte[] inData)
Translates the sign-magnitude representation of an XPBigInteger into an XPBigInteger. |
|
XPBigInteger(int bits,
int confidence,
XPSecureRandom rand)
Generates a random, positive XPBigInteger that is probably prime, with the specified length. |
|
XPBigInteger(int bits,
XPSecureRandom rand)
Populates the XPBigInteger with random bits, resulting in a random number uniformly distributed over the range 0 to (2^numBits - 1). |
|
XPBigInteger(java.lang.String value)
Translates the decimal String representation of an XPBigInteger into an XPBigInteger. |
|
XPBigInteger(java.lang.String value,
int radix)
Translates the String representation of a BigInteger in the specified radix into an XPBigInteger. |
Method Summary | |
---|---|
XPBigInteger |
Abs()
Returns an XPBigInteger containing the absolute value of this. |
XPBigInteger |
Add(XPBigInteger bi2)
Returns an XPBigInteger whose value is this plus the passed in argument. |
XPBigInteger |
And(XPBigInteger bi2)
Returns an XPBigInteger whose value is the logical AND of this and the passed in argument. |
int |
BitLength()
Returns the position of the most significant bit in the XPBigInteger. |
XPBigInteger[] |
DivideAndRemainder(XPBigInteger bi)
Returns an array of two XPBigIntegers that result when dividing this value by the argument passed in. |
boolean |
Equals(XPBigInteger bi)
Returns true if this XPBigInteger has the same value as the passed in argument. |
XPBigInteger |
Gcd(XPBigInteger bi)
Returns the Greatest Common Denominator between this value, and the passed in argument. |
XPBigInteger |
GenCoPrime(int bits,
XPSecureRandom rand)
Returns a random XPBigInteger whose value is relatively prime to the value of this XPBigInteger. |
byte[] |
GetBytes()
Returns an array of bytes containing all the bits of this XPBigInteger. |
int |
GetHashCode()
Provides the BigInteger Object Hashcode value. |
boolean |
GreaterThan(XPBigInteger bi2)
Returns true if this value is greater than the argument passed in. |
int |
IntValue()
Returns an int representing the lowest order 32 bits of this XPBigInteger. |
boolean |
IsProbablePrime(int confidence)
Returns true if this XPBigInteger is probably prime. |
boolean |
LessThan(XPBigInteger bi2)
Returns true if this value is less than the argument passed in. |
long |
LongValue()
Returns a long representing the lowest order 64 bits of this XPBigInteger. |
XPBigInteger |
Max(XPBigInteger bi)
Returns the maximum of this or the passed in argument. |
XPBigInteger |
Min(XPBigInteger bi)
Returns the minimum of this or the passed in argument. |
XPBigInteger |
Mod(XPBigInteger bi)
Returns an XPBigInteger that contains (this % bi). |
XPBigInteger |
ModInverse(XPBigInteger modulus)
Returns an XPBigInteger whose value is this ^ -1 (mod m). |
XPBigInteger |
ModPow(XPBigInteger exp,
XPBigInteger m)
Returns an XPBigInteger whose value is this ^ exp (mod m). |
XPBigInteger |
Multiply(XPBigInteger bi2)
Multiplies this value by the value passed in. |
XPBigInteger |
Negate()
Returns the neagative value of this XPBigInteger. |
XPBigInteger |
Not()
Returns an XPBigInteger that is the logical negation of this value. |
XPBigInteger |
Or(XPBigInteger bi2)
Returns an XPBigInteger whose value is the logical OR of this and the passed in argument. |
void |
SetBit(int bitNum)
Sets the bit at the given index to 1. |
XPBigInteger |
ShiftLeft(int shiftVal)
Returns an XPBigInteger that results from shifting the bits of this value left. |
XPBigInteger |
ShiftRight(int shiftVal)
Returns an XPBigInteger that results from shifting the bits of this value right. |
XPBigInteger |
Sqrt()
Returns an XPBigInteger whose value is equal to the square root of this. |
XPBigInteger |
Subtract(XPBigInteger bi2)
Returns an XPBiginteger whose value is this minus the passed in argument. |
boolean |
TestBit(int bitNum)
Returns true of the bit at the given index is 1, false otherwise. |
java.lang.String |
toString()
Returns the string representation of this XPBigInteger in decimal notation. |
java.lang.String |
toString(int radix)
Returns the string representation of this XPBigInteger in the given radix. |
void |
UnsetBit(int bitNum)
Sets the bit at the given index to 0. |
XPBigInteger |
Xor(XPBigInteger bi2)
Returns an XPBigInteger whose value is the logical XOR of this and the passed in argument. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int maxLength
public static final XPBigInteger ZERO
public static final XPBigInteger ONE
Constructor Detail |
---|
public XPBigInteger(java.lang.String value, int radix)
value
- String representation of BigInteger.radix
- radix to be used in interpreting val.
XPIllegalArgumentException
- val is not a valid representation of a BigInteger in the specified radix, or radix is outside the rangepublic XPBigInteger(java.lang.String value)
value
- decimal String representation of BigInteger.
XPIllegalArgumentException
- val is not a valid representation of a BigInteger.public XPBigInteger(byte[] inData)
inData
- binary representation of BigInteger.public XPBigInteger(int signum, byte[] inData)
signum
- signum of the number (-1 for negative, 0 for zero, 1 for positive).inData
- big-endian binary representation of the magnitude of the number.public XPBigInteger(int bits, XPSecureRandom rand)
bits
- maximum length of the new XPBigInteger.rand
- source of randomness.
XPIllegalArgumentException
- bits is negative.public XPBigInteger(int bits, int confidence, XPSecureRandom rand)
bits
- maximum length of the new XPBigInteger.confidence
- a measure of the uncertainty that the caller is willing to tolerate. The probability that the new XPBigInteger represents a prime number will exceed (1 - 1/2 ^ certainty). The execution time of this constructor is proportional to the value of this parameter.rand
- source of randomness.Method Detail |
---|
public XPBigInteger Add(XPBigInteger bi2)
bi2
- value to add
public XPBigInteger Subtract(XPBigInteger bi2)
bi2
- value to subtract
public XPBigInteger Multiply(XPBigInteger bi2)
bi2
- value to multiply by
public XPBigInteger ShiftLeft(int shiftVal)
shiftVal
- number of bits to shift
public XPBigInteger ShiftRight(int shiftVal)
shiftVal
- number of bits to shift
public XPBigInteger Not()
public XPBigInteger Negate()
public boolean Equals(XPBigInteger bi)
bi
- value to compare to
public int GetHashCode()
public boolean GreaterThan(XPBigInteger bi2)
bi2
- the value to compare to
public boolean LessThan(XPBigInteger bi2)
bi2
- the value to compare to
public XPBigInteger[] DivideAndRemainder(XPBigInteger bi)
bi
- value to divide by
public XPBigInteger Mod(XPBigInteger bi)
bi
- modulus value
public XPBigInteger And(XPBigInteger bi2)
bi2
- value to AND with
public XPBigInteger Or(XPBigInteger bi2)
bi2
- value to OR with
public XPBigInteger Xor(XPBigInteger bi2)
bi2
- value to XOR with
public XPBigInteger Max(XPBigInteger bi)
bi
- value to compare to
public XPBigInteger Min(XPBigInteger bi)
bi
- value to compare to
public XPBigInteger Abs()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toString(int radix)
radix
- radix to use, from 2 to 36.
XPIllegalArgumentException
- if radix is out of range.public XPBigInteger ModPow(XPBigInteger exp, XPBigInteger m)
exp
- exponent valuem
- modulus value
public XPBigInteger Gcd(XPBigInteger bi)
bi
- value to compute gcd with
public int BitLength()
public boolean IsProbablePrime(int confidence)
confidence
- measure of certainty in the primality test
public int IntValue()
public long LongValue()
public XPBigInteger GenCoPrime(int bits, XPSecureRandom rand)
bits
- number of bits in the new XPBigIntegerrand
- source of randomness
public XPBigInteger ModInverse(XPBigInteger modulus)
modulus
- modulus to use
public byte[] GetBytes()
public void SetBit(int bitNum)
bitNum
- bit indexpublic void UnsetBit(int bitNum)
bitNum
- bit indexpublic boolean TestBit(int bitNum)
bitNum
- bit index
public XPBigInteger Sqrt()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |