
JScience v4.3  
PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
java.lang.Object java.lang.Number org.jscience.mathematics.number.Number<Rational> org.jscience.mathematics.number.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.
Field Summary  

static Rational 
ONE
The Rational representing the multiplicative identity. 
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 
copy()
Returns a copy of this number allocated
by the calling thread (possibly on the stack). 
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. 
boolean 
isNegative()
Indicates if this rational number is less than zero. 
boolean 
isPositive()
Indicates if this rational number is greater than zero. 
boolean 
isZero()
Indicates if this rational number is equal to zero. 
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. 
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 value to this rational number. 
Rational 
times(long multiplier)
Returns the product of this rational number with the specified long multiplier. 
Rational 
times(Rational that)
Returns the product of this rational number with the one specified. 
javolution.text.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.number.Number 

byteValue, floatValue, intValue, isGreaterThan, isLessThan, pow, shortValue, toString 
Methods inherited from class java.lang.Object 

clone, finalize, getClass, notify, notifyAll, wait, wait, wait 
Field Detail 

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(long multiplier)
long
multiplier.
multiplier
 the long
multiplier.
this · multiplier
.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 isZero()
this == 0
public boolean isPositive()
this > 0
public boolean isNegative()
this < 0
public boolean isLargerThan(Rational that)
isLargerThan
in class Number<Rational>
that
 the rational number to be compared with.
this > that
public javolution.text.Text toText()
toText
in interface javolution.lang.Realtime
toText
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 Rational copy()
Number
allocated
by the calling thread (possibly on the stack).
copy
in interface javolution.lang.ValueType
copy
in class Number<Rational>

JScience v4.3  
PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 