|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.lang.Number
org.jscience.mathematics.algebraic.numbers.ComparableNumber<ExactRational>
org.jscience.mathematics.algebraic.numbers.ExactRational
public final class ExactRational
The ExactRational class encapsulates rational numbers with infinite precision. Theyt are inbetween ExactInteger and ExactReal.
RationalField,
Serialized Form| Field Summary | |
|---|---|
static int |
DEFAULT_ROUND_MODE
Default round mode, ROUND_HALF_UP. |
static ExactRational |
NaN
|
static ExactRational |
NEGATIVE_INFINITY
|
static ExactRational |
ONE
The exact rational representing the multiplicative identity. |
static ExactRational |
POSITIVE_INFINITY
|
static int |
ROUND_CEILING
Rounding mode to round towards positive infinity. |
static int |
ROUND_DOWN
Rounding mode to round towards zero. |
static int |
ROUND_FLOOR
Rounding mode to round towards negative infinity. |
static int |
ROUND_HALF_CEILING
Rounding mode to round towards nearest neighbor unless both neighbors are equidistant, in which case to round ceiling. |
static int |
ROUND_HALF_DOWN
Rounding mode to round towards nearest neighbor unless both neighbors are equidistant, in which case to round down. |
static int |
ROUND_HALF_EVEN
Rounding mode to round towards the nearest neighbor unless both neighbors are equidistant, in which case to round towards the even neighbor. |
static int |
ROUND_HALF_FLOOR
Rounding mode to round towards nearest neighbor unless both neighbors are equidistant, in which case to round floor. |
static int |
ROUND_HALF_ODD
Rounding mode to round towards the nearest neighbor unless both neighbors are equidistant, in which case to round towards the odd neighbor. |
static int |
ROUND_HALF_UP
Rounding mode to round towards nearest neighbor unless both neighbors are equidistant, in which case to round up. |
static int |
ROUND_UNNECESSARY
Rounding mode to assert that the requested operation has an exact result, hence no rounding is necessary. |
static int |
ROUND_UP
Rounding mode to round away from zero. |
static java.lang.Class |
TYPE
The Class instance representing the type. |
static ExactRational |
ZERO
The exact rational representing the additive identity. |
| Constructor Summary | |
|---|---|
protected |
ExactRational(BigRational num)
Constructs a ExactRational number. |
|
ExactRational(ExactInteger num)
Constructs a ExactRational number. |
|
ExactRational(ExactInteger num,
ExactInteger den)
Constructs a ExactRational number. |
|
ExactRational(ExactRational num)
Constructs a ExactRational number. |
|
ExactRational(int num)
Constructs a ExactRational number. |
|
ExactRational(Integer num)
Constructs a ExactRational number. |
|
ExactRational(long num)
Constructs a ExactRational number. |
|
ExactRational(Long num)
Constructs a ExactRational number. |
|
ExactRational(long num,
long den)
Constructs a ExactRational number. |
|
ExactRational(Long num,
Long den)
Constructs a ExactRational number. |
|
ExactRational(Rational num)
Constructs a ExactRational number. |
|
ExactRational(java.lang.String s)
Constructs the ExactRational number represented by a string. |
| Method Summary | |
|---|---|
ExactRational |
abs()
Returns the abs of this number. |
AbelianGroup.Member |
add(AbelianGroup.Member n)
Returns the addition of this number and another. |
ExactRational |
add(ExactRational n)
Returns the addition of this ExactRational number and another. |
ExactRational |
ceil()
Ceiling, round towards positive infinity. |
java.lang.Object |
clone()
Returns the arc hyperbolic tangent of a number. |
int |
compareTo(ComparableNumber obj)
Compares two numbers. |
int |
compareTo(ExactRational value)
Compares two ExactRational numbers. |
ExactRational |
divide(ExactRational n)
Returns the division of this ExactRational number and another. |
Field.Member |
divide(Field.Member n)
Returns the division of this number and another. |
double |
doubleValue()
|
boolean |
equals(java.lang.Object obj)
Compares two ExactRational numbers for equality. |
float |
floatValue()
|
ExactRational |
floor()
Floor, round towards negative infinity. |
ExactInteger |
fractionalPart()
Retrieves the integer part as a ExactInteger. |
ExactInteger |
getDenominator()
Retrieves the denominator as a ExactReal. |
ExactRational |
getDistance(ComparableNumber n)
DOCUMENT ME! |
ExactRational |
getNaN()
DOCUMENT ME! |
ExactRational |
getNegativeInfinity()
DOCUMENT ME! |
ExactInteger |
getNumerator()
Retrieves the numerator as a ExactInteger. |
ExactRational |
getPositiveInfinity()
DOCUMENT ME! |
int |
hashCode()
Returns the hashcode of this number. |
ExactInteger |
integerPart()
Retrieves the integer part as a ExactInteger. |
int |
intValue()
|
Field.Member |
inverse()
Returns the inverse of this number. |
boolean |
isDefined()
|
boolean |
isInfinite()
Returns true if this number is infinite. |
boolean |
isNaN()
Returns true if this number is NaN. |
boolean |
isNegativeInfinity()
DOCUMENT ME! |
boolean |
isPositiveInfinity()
DOCUMENT ME! |
long |
longValue()
|
ExactRational |
max(ExactRational val)
Returns the max of this number and another, according to compareTo rules. |
ExactRational |
min(ExactRational val)
Returns the min of this number and another, according to compareTo rules. |
ExactRational |
mod(ExactRational that)
Calculate the modulus of two ExactRationals and return a new ExactRational. |
ExactRational |
multiply(ExactRational n)
Returns the multiplication of this ExactRational number and another. |
Ring.Member |
multiply(Ring.Member n)
Returns the multiplication of this number and another. |
AbelianGroup.Member |
negate()
Returns the negative of this number. |
ExactRational |
pow(int i)
Returns this number raised to the power of a number. |
Rational |
rationalValue()
|
ExactRational |
remainder(ExactRational that)
Calculate the remainder of two ExactRationals and return a new ExactRational. |
ExactRational |
round()
Round by default mode. |
ExactRational |
round(int roundMode)
Round. |
int |
signum()
Returns the sign of this number. |
AbelianGroup.Member |
subtract(AbelianGroup.Member n)
Returns the subtraction of this number and another. |
ExactRational |
subtract(ExactRational n)
Returns the subtraction of this ExactRational number and another. |
java.lang.String |
toString()
Returns a string representing the value of this ExactRational number. |
ExactRational |
truncate()
Truncate, round towards zero. |
java.math.BigDecimal |
value()
|
| Methods inherited from class java.lang.Number |
|---|
byteValue, shortValue |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final ExactRational ZERO
public static final ExactRational ONE
public static final ExactRational NEGATIVE_INFINITY
public static final ExactRational POSITIVE_INFINITY
public static final ExactRational NaN
public static final java.lang.Class TYPE
public static final int ROUND_UP
public static final int ROUND_DOWN
public static final int ROUND_CEILING
public static final int ROUND_FLOOR
public static final int ROUND_HALF_UP
public static final int ROUND_HALF_DOWN
public static final int ROUND_HALF_EVEN
public static final int ROUND_UNNECESSARY
public static final int ROUND_HALF_CEILING
public static final int ROUND_HALF_FLOOR
public static final int ROUND_HALF_ODD
public static final int DEFAULT_ROUND_MODE
| Constructor Detail |
|---|
protected ExactRational(BigRational num)
public ExactRational(ExactRational num)
public ExactRational(ExactInteger num,
ExactInteger den)
public ExactRational(ExactInteger num)
public ExactRational(Long num,
Long den)
public ExactRational(Long num)
public ExactRational(Rational num)
public ExactRational(Integer num)
public ExactRational(long num,
long den)
public ExactRational(long num)
public ExactRational(int num)
public ExactRational(java.lang.String s)
throws java.lang.NumberFormatException
s - a string representing a ExactRational number.
java.lang.NumberFormatException - if the string does not contain a parsable number.| Method Detail |
|---|
public ExactInteger integerPart()
public ExactInteger fractionalPart()
public ExactInteger getNumerator()
public ExactInteger getDenominator()
public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - a ExactRational number.
public int compareTo(ComparableNumber obj)
throws java.lang.IllegalArgumentException
obj - a comparable number.
this<obj,
zero if this==obj,
and a positive value if this>obj.
java.lang.IllegalArgumentExceptionpublic int compareTo(ExactRational value)
compareTo in interface java.lang.Comparable<ExactRational>value - a ExactRational number.
this<obj,
zero if this==obj,
and a positive value if this>obj.public java.lang.String toString()
toString in class java.lang.Objectpublic java.math.BigDecimal value()
public int intValue()
intValue in class java.lang.Numberpublic long longValue()
longValue in class java.lang.Numberpublic float floatValue()
floatValue in class java.lang.Numberpublic Rational rationalValue()
public double doubleValue()
doubleValue in class java.lang.Numberpublic ExactRational abs()
public int signum()
public ExactRational min(ExactRational val)
min in class ComparableNumber<ExactRational>val - DOCUMENT ME!
public ExactRational max(ExactRational val)
max in class ComparableNumber<ExactRational>val - DOCUMENT ME!
public int hashCode()
hashCode in class java.lang.Objectpublic boolean isNaN()
isNaN in class ComparableNumber<ExactRational>public boolean isDefined()
public boolean isInfinite()
isInfinite in class ComparableNumber<ExactRational>public boolean isNegativeInfinity()
ComparableNumber
isNegativeInfinity in class ComparableNumber<ExactRational>public boolean isPositiveInfinity()
ComparableNumber
isPositiveInfinity in class ComparableNumber<ExactRational>public ExactRational getNaN()
ComparableNumber
getNaN in class ComparableNumber<ExactRational>public ExactRational getNegativeInfinity()
ComparableNumber
getNegativeInfinity in class ComparableNumber<ExactRational>public ExactRational getPositiveInfinity()
ComparableNumber
getPositiveInfinity in class ComparableNumber<ExactRational>public ExactRational getDistance(ComparableNumber n)
ComparableNumber
getDistance in class ComparableNumber<ExactRational>n - DOCUMENT ME!
public AbelianGroup.Member negate()
negate in interface AbelianGroup.Memberpublic Field.Member inverse()
inverse in interface Field.Memberpublic AbelianGroup.Member add(AbelianGroup.Member n)
add in interface AbelianGroup.Membern - a group member
public ExactRational add(ExactRational n)
public AbelianGroup.Member subtract(AbelianGroup.Member n)
subtract in interface AbelianGroup.Membern - a group member
public ExactRational subtract(ExactRational n)
public Ring.Member multiply(Ring.Member n)
multiply in interface Ring.Membern - a ring member
public ExactRational multiply(ExactRational n)
public Field.Member divide(Field.Member n)
divide in interface Field.Membern - a field member
public ExactRational divide(ExactRational n)
public ExactRational remainder(ExactRational that)
public ExactRational mod(ExactRational that)
public ExactRational round(int roundMode)
public ExactRational round()
public ExactRational floor()
public ExactRational ceil()
public ExactRational truncate()
public ExactRational pow(int i)
public java.lang.Object clone()
clone in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||