public class MPN extends Object implements ByteEncodable
Constructor and Description |
---|
MPN() |
MPN(byte[] encodedBytes,
int offset,
int length) |
MPN(int numWords) |
Modifier and Type | Method and Description |
---|---|
static int |
add_1(int[] dest,
int[] x,
int size,
int y)
Add x[0:size-1] and y, and write the size least
significant words of the result to dest.
|
static int |
add_n(int[] dest,
int[] x,
int[] y,
int len)
Add x[0:len-1] and y[0:len-1] and write the len least
significant words of the result to dest[0:len-1].
|
static int |
chars_per_word(int radix)
Number of digits in the conversion base that always fits in a word.
|
static int |
cmp(int[] x,
int[] y,
int size)
Compare x[0:size-1] with y[0:size-1], treating them as unsigned integers.
|
static int |
cmp(int[] x,
int xlen,
int[] y,
int ylen)
Compare x[0:xlen-1] with y[0:ylen-1], treating them as unsigned integers.
|
int |
compareTo(int value) |
int |
compareTo(long value) |
int |
compareTo(MPN other) |
static int |
count_leading_zeros(int i)
Count the number of leading zero bits in an int.
|
static void |
divide(int[] zds,
int nx,
int[] y,
int ny)
Divide zds[0:nx] by y[0:ny-1].
|
void |
divide(MPN denominator,
MPN quotient,
MPN remainder)
Divide two integers, yielding quotient and remainder.
|
static int |
divmod_1(int[] quotient,
int[] dividend,
int len,
int divisor)
Divide dividend[0:len-1] by (unsigned int)divisor.
|
byte[] |
encodeBytes() |
int |
encodeBytes(ByteArray dest)
This requests the Object to encode itself as a stream of bytes which is appended
to the destination ByteArray.
|
boolean |
equals(int value) |
boolean |
equals(long value) |
static int |
findLowestBit(int word)
Return least i such that word&(1<
|
static int |
findLowestBit(int[] words)
Return least i such that words & (1<
|
MPN |
fromBigInteger(BigInteger bi) |
static int |
gcd(int[] x,
int[] y,
int len)
Calculate Greatest Common Divisior of x[0:len-1] and y[0:len-1].
|
int |
getInt() |
long |
getLong() |
boolean |
hasInt() |
boolean |
hasLong() |
static int |
intLength(int i) |
static int |
intLength(int[] words,
int len)
Calcaulte the Common Lisp "integer-length" function.
|
boolean |
isOdd() |
static int |
lshift(int[] dest,
int d_offset,
int[] x,
int len,
int count) |
MPN |
minimize() |
MPN |
mod(MPN m) |
MPN |
modPowPositive(MPN exponent,
MPN m) |
static int |
mul_1(int[] dest,
int[] x,
int len,
int y)
Multiply x[0:len-1] by y, and write the len least
significant words of the product to dest[0:len-1].
|
static void |
mul(int[] dest,
int[] x,
int xlen,
int[] y,
int ylen)
Multiply x[0:xlen-1] and y[0:ylen-1], and
write the result to dest[0:xlen+ylen-1].
|
MPN |
multiply(MPN y)
Destructively multiply this number with y.
|
static long |
rshift_long(int[] x,
int len,
int count)
Return the long-truncated value of right shifting.
|
static int |
rshift(int[] dest,
int[] x,
int x_start,
int len,
int count) |
static void |
rshift0(int[] dest,
int[] x,
int x_start,
int len,
int count) |
static int |
set_str(int[] dest,
byte[] str,
int str_len,
int base) |
MPN |
set(BigInteger other) |
MPN |
set(int value) |
MPN |
set(int[] data,
int offset,
int length) |
MPN |
set(long value) |
MPN |
set(MPN other) |
static MPN |
set(MPN source,
MPN dest) |
MPN |
shiftLeft(int count)
Destructively shift this MPN to the left by count bits.
|
MPN |
shiftRight(int count)
Destructively shift this MPN to the right by count bits.
|
int |
signum()
This returns -1 if the value is negative, +1 if it is positive, 0 if it is zero.
|
static int |
sub_n(int[] dest,
int[] X,
int[] Y,
int size)
Subtract Y[0:size-1] from X[0:size-1], and write
the size least significant words of the result to dest[0:size-1].
|
static int |
submul_1(int[] dest,
int offset,
int[] x,
int len,
int y) |
BigInteger |
toBigInteger() |
MPN |
toNegative()
Multiply this MPN by -1 and return this.
|
String |
toString()
Return a String representation of this object.
|
String |
toString(int radix) |
static long |
udiv_qrnnd(long N,
int D) |
public MPN(byte[] encodedBytes, int offset, int length) throws StreamCorruptedException
StreamCorruptedException
public MPN()
public MPN(int numWords)
public int encodeBytes(ByteArray dest)
ByteEncodable
encodeBytes
in interface ByteEncodable
dest
- The destination ByteArray, or null to determine the number of bytes needed to encode.public byte[] encodeBytes()
encodeBytes
in interface ByteEncodable
public MPN fromBigInteger(BigInteger bi)
public BigInteger toBigInteger()
public MPN minimize()
public String toString(int radix)
public String toString()
Object
public int signum()
public boolean isOdd()
public MPN set(int[] data, int offset, int length)
public MPN set(BigInteger other)
public MPN set(int value)
public MPN set(long value)
public MPN shiftRight(int count)
count
- the number of bits to shift.public MPN shiftLeft(int count)
count
- the number of bits to shift.public MPN multiply(MPN y)
y
- the number to multiply by.public void divide(MPN denominator, MPN quotient, MPN remainder)
y
- the denominator in the divisionquotient
- is set to the quotient of the result (iff quotient!=null)remainder
- is set to the remainder of the result
(iff remainder!=null)public boolean equals(int value)
public boolean equals(long value)
public int compareTo(int value)
public int compareTo(long value)
public int compareTo(MPN other)
public boolean hasInt()
public boolean hasLong()
public int getInt() throws IllegalStateException
IllegalStateException
public long getLong() throws IllegalStateException
IllegalStateException
public MPN toNegative()
public static int add_1(int[] dest, int[] x, int size, int y)
public static int add_n(int[] dest, int[] x, int[] y, int len)
public static int sub_n(int[] dest, int[] X, int[] Y, int size)
public static int mul_1(int[] dest, int[] x, int len, int y)
public static void mul(int[] dest, int[] x, int xlen, int[] y, int ylen)
public static long udiv_qrnnd(long N, int D)
public static int divmod_1(int[] quotient, int[] dividend, int len, int divisor)
public static int submul_1(int[] dest, int offset, int[] x, int len, int y)
public static void divide(int[] zds, int nx, int[] y, int ny)
public static int chars_per_word(int radix)
radix
- the basepublic static int count_leading_zeros(int i)
public static int set_str(int[] dest, byte[] str, int str_len, int base)
public static int cmp(int[] x, int[] y, int size)
public static int cmp(int[] x, int xlen, int[] y, int ylen)
public static int rshift(int[] dest, int[] x, int x_start, int len, int count)
public static void rshift0(int[] dest, int[] x, int x_start, int len, int count)
public static long rshift_long(int[] x, int len, int count)
x
- a two's-complement "bignum"len
- the number of significant words in xcount
- the shift countpublic static int lshift(int[] dest, int d_offset, int[] x, int len, int count)
public static int findLowestBit(int word)
public static int findLowestBit(int[] words)
public static int gcd(int[] x, int[] y, int len)
public static int intLength(int i)
public static int intLength(int[] words, int len)