jsci.maths
Class MathInteger
- java.lang.Object
-
- java.lang.Number
-
- 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
Constructors Constructor and Description MathInteger(int num)Constructs an integer number.MathInteger(java.lang.String s)Constructs the integer number represented by a string.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description AbelianGroup.Memberadd(AbelianGroup.Member n)Returns the addition of this number and another.MathIntegeradd(int y)MathIntegeradd(MathInteger n)Returns the addition of this integer number and another.intcompareTo(java.lang.Object obj)Compares two integer numbers.doubledoubleValue()booleanequals(java.lang.Object obj)Compares two integer numbers for equality.floatfloatValue()java.lang.ObjectgetSet()inthashCode()intintValue()booleanisEven()Returns true if this number is even.booleanisOdd()Returns true if this number is odd.longlongValue()MathIntegermultiply(int y)MathIntegermultiply(MathInteger n)Returns the multiplication of this integer number and another.Ring.Membermultiply(Ring.Member n)Returns the multiplication of this number and another.AbelianGroup.Membernegate()Returns the negative of this number.MathIntegerpow(MathInteger n)Returns this integer number raised to the power of another.AbelianGroup.Membersubtract(AbelianGroup.Member n)Returns the subtraction of this number and another.MathIntegersubtract(int y)MathIntegersubtract(MathInteger n)Returns the subtraction of this integer number and another.java.lang.StringtoString()Returns a string representing the value of this integer number.intvalue()Returns the integer value.
-
-
-
Constructor Detail
-
MathInteger
public MathInteger(int num)
Constructs an integer number.
-
MathInteger
public MathInteger(java.lang.String s) throws java.lang.NumberFormatExceptionConstructs 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:
equalsin classjava.lang.Object- Parameters:
obj- an integer number.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
compareTo
public int compareTo(java.lang.Object obj) throws java.lang.IllegalArgumentExceptionCompares two integer numbers.- Specified by:
compareToin interfacejava.lang.Comparable- Parameters:
obj- an integer number.- Returns:
- a negative value if
this<obj, zero ifthis==obj, and a positive value ifthis>obj. - Throws:
java.lang.IllegalArgumentException
-
toString
public java.lang.String toString()
Returns a string representing the value of this integer number.- Overrides:
toStringin classjava.lang.Object
-
value
public int value()
Returns the integer value.
-
intValue
public int intValue()
- Specified by:
intValuein classjava.lang.Number
-
longValue
public long longValue()
- Specified by:
longValuein classjava.lang.Number
-
floatValue
public float floatValue()
- Specified by:
floatValuein classjava.lang.Number
-
doubleValue
public double doubleValue()
- Specified by:
doubleValuein classjava.lang.Number
-
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:
negatein interfaceAbelianGroup.Member
-
add
public AbelianGroup.Member add(AbelianGroup.Member n)
Returns the addition of this number and another.- Specified by:
addin interfaceAbelianGroup.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:
subtractin interfaceAbelianGroup.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:
multiplyin interfaceRing.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.
-
-
DMelt 3.0 © DataMelt by jWork.ORG