JSci.maths
Class MathInteger

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

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(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()
           
 int intValue()
           
 boolean isEven()
          Returns true if this number is even.
 boolean isOdd()
          Returns true if this number is odd.
 long longValue()
           
 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(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, hashCode, 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.

Parameters:
obj - an integer number.

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.


value

public int value()
Returns the integer value.


intValue

public int intValue()

longValue

public long longValue()

floatValue

public float floatValue()

doubleValue

public double doubleValue()

isEven

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


isOdd

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


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.


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.

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.

pow

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

Parameters:
n - an integer number.