Class RealInt16
java.lang.Object
org.flag4j.numbers.RealInt16
- All Implemented Interfaces:
Serializable,Comparable<RealInt16>,Ring<RealInt16>,Semiring<RealInt16>
A real number backed by a 16-bit integer number. Immutable
This class wraps the primitive short type.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final RealInt16The numerical value -1.static final RealInt16The numerical value 1.static final RealInt16The numerical value 10.static final RealInt16The numerical value 3.static final RealInt16The numerical value 2.static final RealInt16The numerical value 0. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSums two elements of this ring (associative and commutative).addInv()Computes the additive inverse for an element of this ring.intCompares this element of the ordered ring withb.doubleConverts this semiring value to an equivalent double value.booleanChecks if an object is equal to this ring element.getOne()Gets the multiplicative identity for this semiring.shortgetValue()Gets the value of this ring element.getZero()Gets the additive identity for this semiring.inthashCode()booleanisOne()Checks if this value is a multiplicative identity for this semiring.booleanisZero()Checks if this value is an additive identity for this semiring.doublemag()Computes the magnitude of this ring element.Multiplies two elements of this ring (associative and commutative).static RealInt16Evaluates the signum or sign function on a ring element.Computes difference of two elements of this ring.toString()Converts this ring element to a string representation.
-
Field Details
-
NEGATIVE_ONE
The numerical value -1. -
ZERO
The numerical value 0. -
ONE
The numerical value 1. -
TWO
The numerical value 2. -
THREE
The numerical value 3. -
TEN
The numerical value 10.
-
-
Constructor Details
-
RealInt16
public RealInt16(short value) Constructs a real 16-bit integer number.- Parameters:
value- Value of the 16-bit integer number.
-
-
Method Details
-
getValue
public short getValue()Gets the value of this ring element.- Returns:
- The value of this ring element.
-
add
-
sub
-
mult
-
isZero
public boolean isZero()Checks if this value is an additive identity for this semiring.
An element 0 is an additive identity if a + 0 = a for any a in the semiring.
-
isOne
public boolean isOne()Checks if this value is a multiplicative identity for this semiring.
An element 1 is a multiplicative identity if a * 1 = a for any a in the semiring.
-
getZero
-
getOne
-
addInv
-
mag
-
sgn
Evaluates the signum or sign function on a ring element.- Parameters:
a- Value to evaluate signum function on.- Returns:
- The output of the signum function evaluated on
a:- Returns
RealInt16.ZEROifa.getValue() == 0. - Returns
RealInt16.ONEifa.getValue() > 0. - Returns
RealInt16.NEGATIVE_ONEifa.getValue() < 0.
- Returns
-
compareTo
Compares this element of the ordered ring withb.- Specified by:
compareToin interfaceComparable<RealInt16>- Specified by:
compareToin interfaceSemiring<RealInt16>- Parameters:
b- Second element of the ordered ring.- Returns:
- An int value:
- 0 if this ring element is equal to
b. - invalid input: '<' 0 if this ring element is less than
b. - > 0 if this ring element is greater than
b.
Hence, this method returns zero if and only if the two ring elements are equal, a negative value if and only the ring
element it was called on is less than
band positive if and only if the ring element it was called on is greater thanb. - 0 if this ring element is equal to
-
doubleValue
public double doubleValue()Converts this semiring value to an equivalent double value.- Specified by:
doubleValuein interfaceSemiring<RealInt16>- Returns:
- A double value equivalent to this semiring element.
-
equals
-
hashCode
-
toString
-