JSci.maths
Class MathInteger

java.lang.Object
  extended by java.lang.Number
      extended by JSci.maths.MathInteger
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable, Ring.Member, AbelianGroup.Member, Member

public final class MathInteger
extends java.lang.Number
implements java.lang.Comparable, Ring.Member

The MathInteger class encapsulates integer numbers.

See Also:
IntegerRing, Serialized Form

Constructor Summary
MathInteger(int num)
          Constructs an integer number.
MathInteger(java.lang.String s)
          Constructs the integer number represented by a string.
 
Method Summary
 AbelianGroup.Member add(AbelianGroup.Member n)
          Returns the addition of this number and another.
 MathInteger add(int y)
           
 MathInteger add(MathInteger n)
          Returns the addition of this integer number and another.
 int compareTo(java.lang.Object obj)
          Compares two integer numbers.
 double doubleValue()
           
 boolean equals(java.lang.Object obj)
          Compares two integer numbers for equality.
 float floatValue()
           
 java.lang.Object getSet()
           
 int hashCode()
           
 int intValue()
           
 boolean isEven()
          Returns true if this number is even.
 boolean isOdd()
          Returns true if this number is odd.
 long longValue()
           
 MathInteger multiply(int y)
           
 MathInteger multiply(MathInteger n)
          Returns the multiplication of this integer 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.
 MathInteger pow(MathInteger n)
          Returns this integer number raised to the power of another.
 AbelianGroup.Member subtract(AbelianGroup.Member n)
          Returns the subtraction of this number and another.
 MathInteger subtract(int y)
           
 MathInteger subtract(MathInteger n)
          Returns the subtraction of this integer number and another.
 java.lang.String toString()
          Returns a string representing the value of this integer number.
 int value()
          Returns the integer value.
 
Methods inherited from class java.lang.Number
byteValue, shortValue
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MathInteger

public MathInteger(int num)
Constructs an integer number.


MathInteger

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

Parameters:
s - a string representing an integer 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 integer numbers for equality.

Overrides:
equals in class java.lang.Object
Parameters:
obj - an integer number.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

compareTo

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

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

toString

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

Overrides:
toString in class java.lang.Object

value

public int value()
Returns the integer 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

isEven

public boolean isEven()
Returns true if this number is even.


isOdd

public boolean isOdd()
Returns true if this number is odd.


getSet

public java.lang.Object getSet()
Specified by:
getSet in interface Member

negate

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

Specified by:
negate in interface AbelianGroup.Member

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

add

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


add

public MathInteger add(int y)

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

subtract

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

Parameters:
n - an integer number.

subtract

public MathInteger subtract(int y)

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

multiply

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

Parameters:
n - an integer number.

multiply

public MathInteger multiply(int y)

pow

public MathInteger pow(MathInteger n)
Returns this integer number raised to the power of another.

Parameters:
n - an integer number.