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
Modifier and TypeFieldDescriptionstatic final IntFraction
The fractional representation of negative infinity.static final IntFraction
The fractional representation of an undefined quantity.static final IntFraction
The fractional representation of the number one.static final IntFraction
The fractional representation of positive infinity.static final IntFraction
The fractional representation of the number zero. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionadd
(IntFraction other) int
compareTo
(IntFraction other) divide
(IntFraction other) double
boolean
float
int
Returns the denominator of this fraction.int
Returns the numerator of this fraction.int
hashCode()
boolean
isNaN()
multiply
(IntFraction other) negate()
Returns the formal reciprocal of this fraction.int
signum()
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:
compareTo
in interfaceComparable<IntFraction>
-
signum
public int signum() -
add
-
subtract
-
multiply
-
divide
-
negate
-