Class cryptiX.rsa.BigInt
All Packages Class Hierarchy This Package Previous Next Index
Class cryptiX.rsa.BigInt
java.lang.Object
|
+----java.lang.Number
|
+----cryptiX.rsa.BigInt
- public final class BigInt
- extends Number
-
NEGATIVE_ONE
-
-
ONE
-
-
TWO
-
-
ZERO
-
-
BigInt(BigInt)
- WP
Construct a BigInt with a given BigInt.
-
BigInt(boolean, int[], int)
-
-
BigInt(byte[])
- WP
converts a byte array to a BigInt
-
BigInt(int)
- WP
Construct a BigInt with a given int value.
-
BigInt(long)
- Construct a BigInt with a given long value.
-
abs()
- Return the integer with the same magnitude and positive sign.
-
add(BigInt)
- Return the sum of two BigInts.
-
add(BigInt, BigInt)
- Return the sum of two BigInts.
-
bitLength()
- WP
Returns number of bits for this BigInt
uses the formula: length = ln(BigInt)/ln(2) + 1
-
compare(BigInt)
- Compare to another BigInt.
-
compare(BigInt, BigInt)
- WP bug removed
Compare two BigInt
-
dbg()
-
-
divide(BigInt, BigInt)
- Divide two BigInts, producing the quotient and remainder.
-
doubleValue()
- Returns the value of the number as a double.
-
equals(Object)
- Compare two BigInts for numerical equality.
-
floatValue()
- Returns the value of the number as a float.
-
getBits()
- WP
returns the MASK
-
getMask()
- WP
returns the MASK
-
getOutputRadix()
- WP
gets the output radix
-
hashCode()
-
-
intValue()
- Returns the value of the number as an int.
-
isZero()
- Test for zero.
-
lessThan(BigInt)
- Ordering comparison.
-
longValue()
- Returns the value of the number as a long.
-
mod(BigInt)
- WP
BigInt modulo n
-
multiply(BigInt)
- Return this scaled by multiplicand.
-
multiply(BigInt, BigInt)
- Return product of two BigInts.
-
multiply(long)
- Return this scaled by multiplicand.
-
negate()
- Return the integer with the same magnitude and opposite sign.
-
quotient(BigInt, BigInt)
- Divide two BigInts, producing the quotient.
-
random_digit_exponential(Random, BigInt)
- Used for testing divide.
-
read(DataInput)
- WP
Read a BigInt from a input stream.
-
remainder(BigInt, BigInt)
- Divide two BigInts, returning the remainder
-
setOutputRadix(int)
- WP
sets the output radix for printing
-
shiftLeft()
- WP
Shifts the BigInt 1 bit to the left
-
shiftLeft(int)
- WP
Shifts the BigInt n bits to the left
-
shiftRight()
- WP
Shifts the BigInt 1 bit to the right
-
shiftRight(int)
- WP
Shifts the BigInt n bits to the right
-
subtract(BigInt)
- Return the difference of two BigInts.
-
subtract(BigInt, BigInt)
- Return the difference of two BigInts.
-
test()
- Test the sign of BigInt.
-
testLSB()
- WP
test the LSB of the BigInt
-
toByteArray()
- WP
converts the BigInt to a byte array
MSB in byte[0]
-
toString()
- Convert to a radix-10 String.
-
toString(int)
- Convert to a String.
-
valueOf(String)
- Convert the String into a BigInt integer.
-
valueOf(String, int)
- Convert the String into a BigInt integer.
-
write(DataOutput)
- WP
write a BigInt to a output stream.
ZERO
public final static BigInt ZERO
ONE
public final static BigInt ONE
TWO
public final static BigInt TWO
NEGATIVE_ONE
public final static BigInt NEGATIVE_ONE
BigInt
public BigInt(boolean negative,
int digits[],
int last)
BigInt
public BigInt(byte bytes[])
- WP
converts a byte array to a BigInt
- Parameters:
- negative - is number negative
- bytes - bytearray, bytes[0] contains MSB
BigInt
public BigInt(int n)
- WP
Construct a BigInt with a given int value.
This method is very fast but works only if
- n < RADIX
BigInt
public BigInt(long n)
- Construct a BigInt with a given long value.
BigInt fifty = new BigInt(50);
- See Also:
- valueOf
BigInt
public BigInt(BigInt x)
- WP
Construct a BigInt with a given BigInt.
getMask
public static int getMask()
- WP
returns the MASK
getBits
public static int getBits()
- WP
returns the MASK
hashCode
public int hashCode()
- Overrides:
- hashCode in class Object
bitLength
public int bitLength()
- WP
Returns number of bits for this BigInt
uses the formula: length = ln(BigInt)/ln(2) + 1
isZero
public boolean isZero()
- Test for zero.
num.isZero()
is equivalent to
num.equals(BigInt.ZERO)
but much faster.
equals
public boolean equals(Object obj)
- Compare two BigInts for numerical equality.
Note: equals will return false if obj is not a BigNum,
even if obj makes sense as an integer:
BigInt.valueOf("100").equals(BigInt.valueOf("100")) true
BigInt.valueOf("100").equals(Integer.valueOf("100")) false
- Overrides:
- equals in class Object
lessThan
public boolean lessThan(BigInt comparand)
- Ordering comparison.
test
public int test()
- Test the sign of BigInt.
- Returns:
- -1 if it is negative, 0 if it is zero, and 1 if it is positive.
compare
public int compare(BigInt comparand)
- Compare to another BigInt.
- Parameters:
- comparand - a BigInt to compare against.
- Returns:
- -1 if less than comparand, 0 if equal to comparand,
and 1 if greater than comparand.
compare
public static int compare(BigInt x,
BigInt y)
- WP bug removed
Compare two BigInt
- Parameters:
- x - first BigInt
- y - second BigInt
- Returns:
- -1 if x<y, 0 if x=y, and 1 if x>y
was wrong!!!
corrected by Platzer Wolfgang
add
public BigInt add(BigInt addend)
- Return the sum of two BigInts.
add
public static BigInt add(BigInt x,
BigInt y)
- Return the sum of two BigInts.
negate
public BigInt negate()
- Return the integer with the same magnitude and opposite sign.
abs
public BigInt abs()
- Return the integer with the same magnitude and positive sign.
subtract
public BigInt subtract(BigInt y)
- Return the difference of two BigInts.
subtract
public static BigInt subtract(BigInt x,
BigInt y)
- Return the difference of two BigInts.
multiply
public BigInt multiply(BigInt multiplicand)
- Return this scaled by multiplicand.
multiply
public BigInt multiply(long multiplicand)
- Return this scaled by multiplicand.
multiply
public static BigInt multiply(BigInt x,
BigInt y)
- Return product of two BigInts.
divide
public static BigInt[] divide(BigInt numerator,
BigInt denominator)
- Divide two BigInts, producing the quotient and remainder.
This is more efficient than computing the values separately.
- Returns:
- an array of two BigInts, with the quotient at index 0, and
the remainder at index 1.
quotient
public static BigInt quotient(BigInt numerator,
BigInt denominator)
- Divide two BigInts, producing the quotient.
- See Also:
- divide
remainder
public static BigInt remainder(BigInt numerator,
BigInt denominator)
- Divide two BigInts, returning the remainder
- See Also:
- divide
valueOf
public static BigInt valueOf(String s) throws NumberFormatException
- Convert the String into a BigInt integer. The radix is assumed to be 10.
- Parameters:
- s - the String containing the number
- Throws: NumberFormatException
- The String cannot be parsed as an integer.
valueOf
public static BigInt valueOf(String s,
int radix) throws NumberFormatException
- Convert the String into a BigInt integer.
- Parameters:
- s - the String containing the number
- radix - the radix to be used
- Throws: NumberFormatException
- The String cannot be parsed as an integer.
toByteArray
public byte[] toByteArray()
- WP
converts the BigInt to a byte array
MSB in byte[0]
setOutputRadix
public static void setOutputRadix(int radix)
- WP
sets the output radix for printing
getOutputRadix
public static int getOutputRadix()
- WP
gets the output radix
toString
public String toString()
- Convert to a radix-10 String.
- Overrides:
- toString in class Object
toString
public String toString(int radix)
- Convert to a String.
- Parameters:
- radix - the radix to be used
dbg
public String dbg()
intValue
public int intValue()
- Returns the value of the number as an int.
- Throws: ArithmeticException
- The number is too great to be represented as an int.
- Overrides:
- intValue in class Number
longValue
public long longValue()
- Returns the value of the number as a long.
- Throws: ArithmeticException
- The number is too big to be represented as a long.
- Overrides:
- longValue in class Number
floatValue
public float floatValue()
- Returns the value of the number as a float.
This may involve loss of precision or overflow.
- Overrides:
- floatValue in class Number
doubleValue
public double doubleValue()
- Returns the value of the number as a double.
This may involve loss of precision or overflow.
- Overrides:
- doubleValue in class Number
random_digit_exponential
public static BigInt random_digit_exponential(Random rng,
BigInt limit)
- Used for testing divide. Generates numbers with an exponential-like
distribution. Not otherwise useful.
shiftRight
public void shiftRight()
- WP
Shifts the BigInt 1 bit to the right
shiftLeft
public void shiftLeft()
- WP
Shifts the BigInt 1 bit to the left
shiftRight
public void shiftRight(int n)
- WP
Shifts the BigInt n bits to the right
shiftLeft
public void shiftLeft(int n)
- WP
Shifts the BigInt n bits to the left
testLSB
public boolean testLSB()
- WP
test the LSB of the BigInt
mod
public BigInt mod(BigInt n)
- WP
BigInt modulo n
read
public static BigInt read(DataInput in) throws IOException
- WP
Read a BigInt from a input stream.
write
public void write(DataOutput out) throws IOException
- WP
write a BigInt to a output stream.
All Packages Class Hierarchy This Package Previous Next Index