Package eu.bandm.sig.adlib2
Class IntFraction
java.lang.Object
eu.bandm.sig.adlib2.IntFraction
- All Implemented Interfaces:
Comparable<IntFraction>
Representation of fractions.
A fraction is a pair of values, namely the numerator and the denominator, respectively, and represents their quotient.
This class provides fractional arithmetic operations. Note that those are
not optimized for high performance or low memory usage. Thus, computations
implemented by this class should be used only at construction time of a
network. For realtime fractional computations, use IntSignalSourceFraction instead.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final IntFractionThe fractional representation of negative infinity.static final IntFractionThe fractional representation of an undefined quantity.static final IntFractionThe fractional representation of the number one.static final IntFractionThe fractional representation of positive infinity.static final IntFractionThe fractional representation of the number zero. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd(IntFraction other) intcompareTo(IntFraction other) divide(IntFraction other) doublebooleanfloatintReturns the denominator of this fraction.intReturns the numerator of this fraction.inthashCode()booleanisNaN()multiply(IntFraction other) negate()Returns the formal reciprocal of this fraction.intsignum()subtract(IntFraction other) toString()
-
Field Details
-
ZERO
The fractional representation of the number zero. -
ONE
The fractional representation of the number one. -
POSITIVE_INFINITY
The fractional representation of positive infinity. -
NEGATIVE_INFINITY
The fractional representation of negative infinity. -
NOT_A_NUMBER
The fractional representation of an undefined quantity.
-
-
Constructor Details
-
IntFraction
public IntFraction(int numerator, int denominator)
-
-
Method Details
-
getNumerator
public int getNumerator()Returns the numerator of this fraction. -
getDenominator
public int getDenominator()Returns the denominator of this fraction. -
equals
-
hashCode
public int hashCode() -
toString
-
reciprocal
Returns the formal reciprocal of this fraction.- Returns:
- a fraction where numerator and denominator are exchanged
-
floatValue
public float floatValue() -
doubleValue
public double doubleValue() -
isNaN
public boolean isNaN() -
compareTo
- Specified by:
compareToin interfaceComparable<IntFraction>
-
signum
public int signum() -
add
-
subtract
-
multiply
-
divide
-
negate
-