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

Variable Index

 o NEGATIVE_ONE
 o ONE
 o TWO
 o ZERO

Constructor Index

 o BigInt(BigInt)
WP Construct a BigInt with a given BigInt.
 o BigInt(boolean, int[], int)
 o BigInt(byte[])
WP converts a byte array to a BigInt
 o BigInt(int)
WP Construct a BigInt with a given int value.
 o BigInt(long)
Construct a BigInt with a given long value.

Method Index

 o abs()
Return the integer with the same magnitude and positive sign.
 o add(BigInt)
Return the sum of two BigInts.
 o add(BigInt, BigInt)
Return the sum of two BigInts.
 o bitLength()
WP Returns number of bits for this BigInt uses the formula: length = ln(BigInt)/ln(2) + 1
 o compare(BigInt)
Compare to another BigInt.
 o compare(BigInt, BigInt)
WP bug removed Compare two BigInt
 o dbg()
 o divide(BigInt, BigInt)
Divide two BigInts, producing the quotient and remainder.
 o doubleValue()
Returns the value of the number as a double.
 o equals(Object)
Compare two BigInts for numerical equality.
 o floatValue()
Returns the value of the number as a float.
 o getBits()
WP returns the MASK
 o getMask()
WP returns the MASK
 o getOutputRadix()
WP gets the output radix
 o hashCode()
 o intValue()
Returns the value of the number as an int.
 o isZero()
Test for zero.
 o lessThan(BigInt)
Ordering comparison.
 o longValue()
Returns the value of the number as a long.
 o mod(BigInt)
WP BigInt modulo n
 o multiply(BigInt)
Return this scaled by multiplicand.
 o multiply(BigInt, BigInt)
Return product of two BigInts.
 o multiply(long)
Return this scaled by multiplicand.
 o negate()
Return the integer with the same magnitude and opposite sign.
 o quotient(BigInt, BigInt)
Divide two BigInts, producing the quotient.
 o random_digit_exponential(Random, BigInt)
Used for testing divide.
 o read(DataInput)
WP Read a BigInt from a input stream.
 o remainder(BigInt, BigInt)
Divide two BigInts, returning the remainder
 o setOutputRadix(int)
WP sets the output radix for printing
 o shiftLeft()
WP Shifts the BigInt 1 bit to the left
 o shiftLeft(int)
WP Shifts the BigInt n bits to the left
 o shiftRight()
WP Shifts the BigInt 1 bit to the right
 o shiftRight(int)
WP Shifts the BigInt n bits to the right
 o subtract(BigInt)
Return the difference of two BigInts.
 o subtract(BigInt, BigInt)
Return the difference of two BigInts.
 o test()
Test the sign of BigInt.
 o testLSB()
WP test the LSB of the BigInt
 o toByteArray()
WP converts the BigInt to a byte array MSB in byte[0]
 o toString()
Convert to a radix-10 String.
 o toString(int)
Convert to a String.
 o valueOf(String)
Convert the String into a BigInt integer.
 o valueOf(String, int)
Convert the String into a BigInt integer.
 o write(DataOutput)
WP write a BigInt to a output stream.

Variables

 o ZERO
  public final static BigInt ZERO
 o ONE
  public final static BigInt ONE
 o TWO
  public final static BigInt TWO
 o NEGATIVE_ONE
  public final static BigInt NEGATIVE_ONE

Constructors

 o BigInt
  public BigInt(boolean negative,
                int digits[],
                int last)
 o BigInt
  public BigInt(byte bytes[])
WP converts a byte array to a BigInt
Parameters:
negative - is number negative
bytes - bytearray, bytes[0] contains MSB
 o 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
 o BigInt
  public BigInt(long n)
Construct a BigInt with a given long value.
  BigInt fifty = new BigInt(50);
See Also:
valueOf
 o BigInt
  public BigInt(BigInt x)
WP Construct a BigInt with a given BigInt.

Methods

 o getMask
  public static int getMask()
WP returns the MASK
 o getBits
  public static int getBits()
WP returns the MASK
 o hashCode
  public int hashCode()
Overrides:
hashCode in class Object
 o bitLength
  public int bitLength()
WP Returns number of bits for this BigInt uses the formula: length = ln(BigInt)/ln(2) + 1
 o isZero
  public boolean isZero()
Test for zero. num.isZero() is equivalent to num.equals(BigInt.ZERO) but much faster.
 o 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
 o lessThan
  public boolean lessThan(BigInt comparand)
Ordering comparison.
 o 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.
 o 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.
 o 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
 o add
  public BigInt add(BigInt addend)
Return the sum of two BigInts.
 o add
  public static BigInt add(BigInt x,
                           BigInt y)
Return the sum of two BigInts.
 o negate
  public BigInt negate()
Return the integer with the same magnitude and opposite sign.
 o abs
  public BigInt abs()
Return the integer with the same magnitude and positive sign.
 o subtract
  public BigInt subtract(BigInt y)
Return the difference of two BigInts.
 o subtract
  public static BigInt subtract(BigInt x,
                                BigInt y)
Return the difference of two BigInts.
 o multiply
  public BigInt multiply(BigInt multiplicand)
Return this scaled by multiplicand.
 o multiply
  public BigInt multiply(long multiplicand)
Return this scaled by multiplicand.
 o multiply
  public static BigInt multiply(BigInt x,
                                BigInt y)
Return product of two BigInts.
 o 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.
 o quotient
  public static BigInt quotient(BigInt numerator,
                                BigInt denominator)
Divide two BigInts, producing the quotient.
See Also:
divide
 o remainder
  public static BigInt remainder(BigInt numerator,
                                 BigInt denominator)
Divide two BigInts, returning the remainder
See Also:
divide
 o 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.
 o 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.
 o toByteArray
  public byte[] toByteArray()
WP converts the BigInt to a byte array MSB in byte[0]
 o setOutputRadix
  public static void setOutputRadix(int radix)
WP sets the output radix for printing
 o getOutputRadix
  public static int getOutputRadix()
WP gets the output radix
 o toString
  public String toString()
Convert to a radix-10 String.
Overrides:
toString in class Object
 o toString
  public String toString(int radix)
Convert to a String.
Parameters:
radix - the radix to be used
 o dbg
  public String dbg()
 o 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
 o 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
 o 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
 o 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
 o 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.
 o shiftRight
  public void shiftRight()
WP Shifts the BigInt 1 bit to the right
 o shiftLeft
  public void shiftLeft()
WP Shifts the BigInt 1 bit to the left
 o shiftRight
  public void shiftRight(int n)
WP Shifts the BigInt n bits to the right
 o shiftLeft
  public void shiftLeft(int n)
WP Shifts the BigInt n bits to the left
 o testLSB
  public boolean testLSB()
WP test the LSB of the BigInt
 o mod
  public BigInt mod(BigInt n)
WP BigInt modulo n
 o read
  public static BigInt read(DataInput in) throws IOException
WP Read a BigInt from a input stream.
 o 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