org.jscience.mathematics.algebraic.numbers
Class ExactInteger

java.lang.Object
  extended by java.lang.Number
      extended by org.jscience.mathematics.algebraic.numbers.ComparableNumber<ExactInteger>
          extended by org.jscience.mathematics.algebraic.numbers.ExactInteger
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<ExactInteger>, Ring.Member, AbelianGroup.Member, Member

public final class ExactInteger
extends ComparableNumber<ExactInteger>
implements java.lang.Cloneable, java.io.Serializable, Ring.Member

The ExactInteger class encapsulates integer numbers with infinite precision but slower speed than Integer or Long.

See Also:
IntegerRing, Serialized Form

Field Summary
static ExactInteger NaN
           
static ExactInteger NEGATIVE_INFINITY
           
static ExactInteger ONE
          The exact integer representing the multiplicative identity.
static ExactInteger POSITIVE_INFINITY
           
static java.lang.Class TYPE
           
static ExactInteger ZERO
          The exact integer representing the additive identity.
 
Constructor Summary
ExactInteger(java.math.BigInteger num)
          Constructs a ExactInteger number.
ExactInteger(ExactInteger num)
          Constructs a ExactInteger number.
ExactInteger(int num)
          Constructs a ExactInteger number.
ExactInteger(Integer num)
          Constructs a ExactInteger number.
ExactInteger(long num)
          Constructs a ExactInteger number.
ExactInteger(Long num)
          Constructs a ExactInteger number.
ExactInteger(java.lang.String s)
          Constructs the ExactInteger number represented by a string.
 
Method Summary
 ExactInteger abs()
          Returns the abs of this number.
 AbelianGroup.Member add(AbelianGroup.Member n)
          Returns the addition of this number and another.
 ExactInteger add(ExactInteger n)
          Returns the addition of this ExactInteger number and another.
 java.lang.Object clone()
          Returns the arc hyperbolic tangent of a number.
 int compareTo(ComparableNumber obj)
          Compares two numbers.
 int compareTo(ExactInteger value)
          Compares two ExactInteger numbers.
 double doubleValue()
           
 boolean equals(java.lang.Object obj)
          Compares two ExactInteger numbers for equality.
 float floatValue()
           
 ExactInteger getDistance(ComparableNumber n)
          DOCUMENT ME!
 ExactInteger getNaN()
          DOCUMENT ME!
 ExactInteger getNegativeInfinity()
          DOCUMENT ME!
 ExactInteger getPositiveInfinity()
          DOCUMENT ME!
 int hashCode()
          Returns the hashcode of this number.
 int intValue()
           
 boolean isInfinite()
          Returns true if this number is infinite.
 boolean isNaN()
          Returns true if this number is NaN.
 boolean isNegativeInfinity()
          DOCUMENT ME!
 boolean isPositiveInfinity()
          DOCUMENT ME!
 long longValue()
           
 ExactInteger max(ExactInteger val)
          Returns the max of this number and another, according to compareTo rules.
 ExactInteger min(ExactInteger val)
          Returns the min of this number and another, according to compareTo rules.
 ExactInteger multiply(ExactInteger n)
          Returns the multiplication of this ExactInteger number and another.
 Ring.Member multiply(Ring.Member n)
          Returns the multiplication of this number and another.
 AbelianGroup.Member negate()
          Returns the negative of this number.
 ExactInteger pow(int i)
          Returns this number raised to the power of a number.
 int signum()
          Returns the sign of this number.
 AbelianGroup.Member subtract(AbelianGroup.Member n)
          Returns the subtraction of this number and another.
 ExactInteger subtract(ExactInteger n)
          Returns the subtraction of this ExactInteger number and another.
 java.lang.String toString()
          Returns a string representing the value of this ExactInteger number.
 java.math.BigInteger value()
           
 
Methods inherited from class java.lang.Number
byteValue, shortValue
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ZERO

public static final ExactInteger ZERO
The exact integer representing the additive identity.


ONE

public static final ExactInteger ONE
The exact integer representing the multiplicative identity.


NEGATIVE_INFINITY

public static final ExactInteger NEGATIVE_INFINITY

POSITIVE_INFINITY

public static final ExactInteger POSITIVE_INFINITY

NaN

public static final ExactInteger NaN

TYPE

public static final java.lang.Class TYPE
Constructor Detail

ExactInteger

public ExactInteger(ExactInteger num)
Constructs a ExactInteger number.


ExactInteger

public ExactInteger(java.math.BigInteger num)
Constructs a ExactInteger number.


ExactInteger

public ExactInteger(Long num)
Constructs a ExactInteger number.


ExactInteger

public ExactInteger(Integer num)
Constructs a ExactInteger number.


ExactInteger

public ExactInteger(long num)
Constructs a ExactInteger number.


ExactInteger

public ExactInteger(int num)
Constructs a ExactInteger number.


ExactInteger

public ExactInteger(java.lang.String s)
             throws java.lang.NumberFormatException
Constructs the ExactInteger number represented by a string.

Parameters:
s - a string representing a ExactInteger number.
Throws:
java.lang.NumberFormatException - if the string does not contain a parsable number.
Method Detail

equals

public boolean equals(java.lang.Object obj)
Compares two ExactInteger numbers for equality.

Overrides:
equals in class java.lang.Object
Parameters:
obj - a ExactInteger number.

compareTo

public int compareTo(ComparableNumber obj)
              throws java.lang.IllegalArgumentException
Compares two numbers.

Parameters:
obj - a comparable number.
Returns:
a negative value if this<obj, zero if this==obj, and a positive value if this>obj.
Throws:
java.lang.IllegalArgumentException

compareTo

public int compareTo(ExactInteger value)
Compares two ExactInteger numbers.

Specified by:
compareTo in interface java.lang.Comparable<ExactInteger>
Parameters:
value - a ExactInteger number.
Returns:
a negative value if this<obj, zero if this==obj, and a positive value if this>obj.

toString

public java.lang.String toString()
Returns a string representing the value of this ExactInteger number.

Overrides:
toString in class java.lang.Object

value

public java.math.BigInteger value()

intValue

public int intValue()
Specified by:
intValue in class java.lang.Number

longValue

public long longValue()
Specified by:
longValue in class java.lang.Number

floatValue

public float floatValue()
Specified by:
floatValue in class java.lang.Number

doubleValue

public double doubleValue()
Specified by:
doubleValue in class java.lang.Number

abs

public ExactInteger abs()
Returns the abs of this number.


signum

public int signum()
Returns the sign of this number.


min

public ExactInteger min(ExactInteger val)
Returns the min of this number and another, according to compareTo rules.

Overrides:
min in class ComparableNumber<ExactInteger>
Parameters:
val - DOCUMENT ME!
Returns:
DOCUMENT ME!

max

public ExactInteger max(ExactInteger val)
Returns the max of this number and another, according to compareTo rules.

Overrides:
max in class ComparableNumber<ExactInteger>
Parameters:
val - DOCUMENT ME!
Returns:
DOCUMENT ME!

hashCode

public int hashCode()
Returns the hashcode of this number.

Overrides:
hashCode in class java.lang.Object

isNaN

public boolean isNaN()
Returns true if this number is NaN.

Specified by:
isNaN in class ComparableNumber<ExactInteger>
Returns:
DOCUMENT ME!

isInfinite

public boolean isInfinite()
Returns true if this number is infinite.

Specified by:
isInfinite in class ComparableNumber<ExactInteger>
Returns:
DOCUMENT ME!

isNegativeInfinity

public boolean isNegativeInfinity()
Description copied from class: ComparableNumber
DOCUMENT ME!

Specified by:
isNegativeInfinity in class ComparableNumber<ExactInteger>
Returns:
DOCUMENT ME!

isPositiveInfinity

public boolean isPositiveInfinity()
Description copied from class: ComparableNumber
DOCUMENT ME!

Specified by:
isPositiveInfinity in class ComparableNumber<ExactInteger>
Returns:
DOCUMENT ME!

getNaN

public ExactInteger getNaN()
Description copied from class: ComparableNumber
DOCUMENT ME!

Specified by:
getNaN in class ComparableNumber<ExactInteger>
Returns:
DOCUMENT ME!

getNegativeInfinity

public ExactInteger getNegativeInfinity()
Description copied from class: ComparableNumber
DOCUMENT ME!

Specified by:
getNegativeInfinity in class ComparableNumber<ExactInteger>
Returns:
DOCUMENT ME!

getPositiveInfinity

public ExactInteger getPositiveInfinity()
Description copied from class: ComparableNumber
DOCUMENT ME!

Specified by:
getPositiveInfinity in class ComparableNumber<ExactInteger>
Returns:
DOCUMENT ME!

getDistance

public ExactInteger getDistance(ComparableNumber n)
Description copied from class: ComparableNumber
DOCUMENT ME!

Specified by:
getDistance in class ComparableNumber<ExactInteger>
Parameters:
n - DOCUMENT ME!
Returns:
DOCUMENT ME!

negate

public AbelianGroup.Member negate()
Returns the negative of this number.

Specified by:
negate in interface AbelianGroup.Member
Returns:
DOCUMENT ME!

add

public AbelianGroup.Member add(AbelianGroup.Member n)
Returns the addition of this number and another.

Specified by:
add in interface AbelianGroup.Member
Parameters:
n - a group member
Returns:
DOCUMENT ME!

add

public ExactInteger add(ExactInteger n)
Returns the addition of this ExactInteger number and another.


subtract

public AbelianGroup.Member subtract(AbelianGroup.Member n)
Returns the subtraction of this number and another.

Specified by:
subtract in interface AbelianGroup.Member
Parameters:
n - a group member
Returns:
DOCUMENT ME!

subtract

public ExactInteger subtract(ExactInteger n)
Returns the subtraction of this ExactInteger number and another.


multiply

public Ring.Member multiply(Ring.Member n)
Returns the multiplication of this number and another.

Specified by:
multiply in interface Ring.Member
Parameters:
n - a ring member
Returns:
DOCUMENT ME!

multiply

public ExactInteger multiply(ExactInteger n)
Returns the multiplication of this ExactInteger number and another.


pow

public ExactInteger pow(int i)
Returns this number raised to the power of a number.


clone

public java.lang.Object clone()
Returns the arc hyperbolic tangent of a number.

Overrides:
clone in class java.lang.Object