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