|
JScience v3.3 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavolution.context.RealtimeObject
org.jscience.mathematics.numbers.Number<Rational>
org.jscience.mathematics.numbers.Rational
public final class Rational
This class represents the ratio of two LargeInteger numbers.
Instances of this class are immutable and can be used to find exact
solutions to linear equations with the Matrix class.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class javolution.context.RealtimeObject |
|---|
RealtimeObject.Factory<T extends RealtimeObject> |
| Nested classes/interfaces inherited from interface javolution.context.Realtime |
|---|
Realtime.ObjectSpace |
| Field Summary | |
|---|---|
static Rational |
ONE
The Rational representing the multiplicative identity. |
protected static XMLFormat<Rational> |
XML
Holds the default XML representation for rational numbers. |
static Rational |
ZERO
The Rational representing the additive identity. |
| Method Summary | |
|---|---|
Rational |
abs()
Returns the absolute value of this rational number. |
int |
compareTo(Rational that)
Compares two rational number numerically. |
Rational |
divide(Rational that)
Returns this rational number divided by the one specified. |
double |
doubleValue()
Returns the value of this rational number as a double. |
boolean |
equals(java.lang.Object that)
Compares this rational number against the specified object. |
LargeInteger |
getDividend()
Returns the smallest dividend of the fraction representing this rational number. |
LargeInteger |
getDivisor()
Returns the smallest divisor of the fraction representing this rational (always positive). |
int |
hashCode()
Returns the hash code for this rational number. |
Rational |
inverse()
Returns the inverse of this rational number. |
boolean |
isLargerThan(Rational that)
Compares the absolute value of two rational numbers. |
long |
longValue()
Returns the value of this rational number as a long. |
Rational |
minus(Rational that)
Returns the difference between this rational number and the one specified. |
boolean |
move(Realtime.ObjectSpace os)
Moves this real-time object to the specified object space. |
Rational |
opposite()
Returns the opposite of this rational number. |
Rational |
plus(Rational that)
Returns the sum of this rational number with the one specified. |
LargeInteger |
round()
Returns the closest integer to this rational number. |
Rational |
times(Rational that)
Returns the product of this rational number with the one specified. |
Text |
toText()
Returns the decimal text representation of this number. |
static Rational |
valueOf(java.lang.CharSequence chars)
Returns the rational number for the specified character sequence. |
static Rational |
valueOf(LargeInteger dividend,
LargeInteger divisor)
Returns the rational number for the specified large integer dividend and divisor. |
static Rational |
valueOf(long dividend,
long divisor)
Returns the rational number for the specified integer dividend and divisor. |
| Methods inherited from class org.jscience.mathematics.numbers.Number |
|---|
byteValue, floatValue, intValue, isGreaterThan, isLessThan, pow, shortValue |
| Methods inherited from class javolution.context.RealtimeObject |
|---|
export, isLocal, moveHeap, preserve, toString, unpreserve |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected static final XMLFormat<Rational> XML
value attribute
holding the textual representation.
public static final Rational ZERO
Rational representing the additive identity.
public static final Rational ONE
Rational representing the multiplicative identity.
| Method Detail |
|---|
public static Rational valueOf(long dividend,
long divisor)
dividend - the dividend value.divisor - the divisor value.
dividend / divisor
java.lang.ArithmeticException - if divisor == 0
public static Rational valueOf(LargeInteger dividend,
LargeInteger divisor)
dividend - the dividend value.divisor - the divisor value.
dividend / divisor
java.lang.ArithmeticException - if divisor.isZero()public static Rational valueOf(java.lang.CharSequence chars)
chars - the character sequence.
public LargeInteger getDividend()
public LargeInteger getDivisor()
public LargeInteger round()
public Rational opposite()
opposite in interface GroupAdditive<Rational>-this.public Rational plus(Rational that)
plus in interface GroupAdditive<Rational>that - the rational number to be added.
this + that.public Rational minus(Rational that)
minus in class Number<Rational>that - the rational number to be subtracted.
this - that.public Rational times(Rational that)
times in interface GroupMultiplicative<Rational>times in interface Ring<Rational>that - the rational number multiplier.
this ยท that.public Rational inverse()
inverse in interface GroupMultiplicative<Rational>1 / this.
java.lang.ArithmeticException - if dividend.isZero()public Rational divide(Rational that)
that - the rational number divisor.
this / that.
java.lang.ArithmeticException - if that.equals(ZERO)public Rational abs()
|this|.public boolean isLargerThan(Rational that)
isLargerThan in class Number<Rational>that - the rational number to be compared with.
|this| > |that|public Text toText()
toText in interface RealtimetoText in class Number<Rational>public boolean equals(java.lang.Object that)
equals in class Number<Rational>that - the object to compare with.
true if the objects are the same;
false otherwise.public int hashCode()
hashCode in class Number<Rational>public long longValue()
long.
longValue in class Number<Rational>long.public double doubleValue()
double.
doubleValue in class Number<Rational>double.public int compareTo(Rational that)
compareTo in interface java.lang.Comparable<Rational>compareTo in class Number<Rational>that - the rational number to compare with.
that.public boolean move(Realtime.ObjectSpace os)
Number
move in interface Realtimemove in class Number<Rational>os - the object space to move this real-time object to.
true if the move has to be propagated to
external real-time references; false otherwise.
|
JScience v3.3 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||