public class IntFraction extends Object implements Comparable<IntFraction>
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.
Modifier and Type | Field and Description |
---|---|
static IntFraction |
NEGATIVE_INFINITY
The fractional representation of negative infinity.
|
static IntFraction |
NOT_A_NUMBER
The fractional representation of an undefined quantity.
|
static IntFraction |
ONE
The fractional representation of the number one.
|
static IntFraction |
POSITIVE_INFINITY
The fractional representation of positive infinity.
|
static IntFraction |
ZERO
The fractional representation of the number zero.
|
Constructor and Description |
---|
IntFraction(int numerator,
int denominator) |
Modifier and Type | Method and Description |
---|---|
IntFraction |
add(IntFraction other) |
int |
compareTo(IntFraction other) |
IntFraction |
divide(IntFraction other) |
double |
doubleValue() |
boolean |
equals(Object o) |
float |
floatValue() |
int |
getDenominator()
Returns the denominator of this fraction.
|
int |
getNumerator()
Returns the numerator of this fraction.
|
int |
hashCode() |
boolean |
isNaN() |
IntFraction |
multiply(IntFraction other) |
IntFraction |
negate() |
IntFraction |
reciprocal()
Returns the formal reciprocal of this fraction.
|
int |
signum() |
IntFraction |
subtract(IntFraction other) |
String |
toString() |
public static final IntFraction ZERO
public static final IntFraction ONE
public static final IntFraction POSITIVE_INFINITY
public static final IntFraction NEGATIVE_INFINITY
public static final IntFraction NOT_A_NUMBER
public int getNumerator()
public int getDenominator()
public IntFraction reciprocal()
public float floatValue()
public double doubleValue()
public boolean isNaN()
public int compareTo(IntFraction other)
compareTo
in interface Comparable<IntFraction>
public int signum()
public IntFraction add(IntFraction other)
public IntFraction subtract(IntFraction other)
public IntFraction multiply(IntFraction other)
public IntFraction divide(IntFraction other)
public IntFraction negate()