|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--com.rubecula.jquantity.Item
|
+--com.rubecula.jquantity.BaseNumber
|
+--com.rubecula.jquantity.MutableNumber
|
+--com.rubecula.jquantity.DivisibleMutable
|
+--com.rubecula.jquantity.Rational
Public class to represent precise rational numbers.
What's wrong with BigDecimal, you might ask?
BigDecimal can only represent rational numbers where the denominator is a
power of ten.
Many numbers are just not like that.
Furthermore, both numerator and denominator can be either exact integers
(i.e. Manifests or WholeNumbers) or fuzzy integers (i.e. FuzzInt)
so that Rational can
itself represent a complete range of potentially fuzzy numbers.
Infinity is a legal Rational number.
| Nested Class Summary | |
class |
Rational.RValueException
Title: RValueException |
| Field Summary | |
protected BaseNumber |
_Denominator
_Denominator is the denominator of the rational quantity defined by this. |
protected double |
_Estimate
_Estimate is the best estimate of the value (STRICTLY for debugging purposes only). |
protected BaseNumber |
_Numerator
_Numerator is the numerator of the rational quantity defined by this. |
(package private) static Rational |
$_c
By definition, the velocity of light: 299792458. |
(package private) static Rational |
$_degF
Degrees Fahrenheit/Celsius offset: 32. |
(package private) static Rational |
$_degR
Degrees Rankine/Kelvin conversion: 5/9. |
static Rational |
$_Log10_E
|
(package private) static Rational |
$_Pi_2
|
(package private) static Rational |
$_Pi_4
|
(package private) static Rational |
$_Tan15Deg
2 - $Rt3. |
(package private) static Rational |
$_Tan22_5Deg
1 / (1 + Rt2). |
(package private) static Rational |
$_Tan30Deg
1/$Rt3. |
static Rational |
$0
$0 is the Rational representation of the exact value 0. |
static Rational |
$1
$1 is the Rational representation of the exact value 1. |
static Rational |
$1_2
$1_2 is the Rational representation of the exact value 1/2. |
static Rational |
$10
$10 is the Rational representation of the exact value 10. |
(package private) static Rational |
$12
|
static Rational |
$2
$2 is the Rational representation of the exact value 2. |
(package private) static Rational |
$3
|
(package private) static Rational |
$6
|
static Rational |
$E
Value of E as a Rational. |
static Rational |
$Infinity
$Infinity is the Rational representation of the (exact) value of infinity, i.e. |
(package private) static Rational |
$NaN
|
static Rational |
$Pi
Value of Pi as a Rational. |
(package private) static Rational |
$Rt2
InitialValueOf($S_Rt2). |
(package private) static Rational |
$Rt3
InitialValueOf($S_Rt3). |
(package private) static Rational |
$Rt5
InitialValueOf($S_Rt5). |
(package private) static java.lang.String |
$S_Rt2
1.414213562373095048801688724209698078569671875377 |
(package private) static java.lang.String |
$S_Rt3
1.732050807568877293527446341505872366942805253810 |
(package private) static java.lang.String |
$S_Rt5
2.2360679774997896964091736687312762354406183596 |
| Fields inherited from class com.rubecula.jquantity.MutableNumber |
$__1 |
| Fields inherited from interface com.rubecula.jquantity.Fuzzy |
$DistGaussian, $DistInvalid, $DistNone, $DistUniform, $Names |
| Constructor Summary | |
|
Rational()
Empty constructor to make an undefined Rational object. |
(package private) |
Rational(java.math.BigDecimal x)
|
protected |
Rational(java.math.BigDecimal x,
java.lang.String identifier)
Factory method to create a Rational from a BigDecimal value and an identifier. |
|
Rational(Integral value)
Constructs a non-explicitly identified Rational representing the ratio of value divided by unity. |
|
Rational(Integral numerator,
Integral denominator)
Constructs a non-explicitly identified, normalized Rational representing the ratio of numerator divided by denominator. |
protected |
Rational(Integral numerator,
Integral denominator,
boolean normalize)
Constructs a non-explicitly identified Rational representing the ratio of numerator divided by denominator, with optional normalization. |
protected |
Rational(Integral numerator,
Integral denominator,
boolean normalize,
java.lang.String identifier)
Constructs an identified Rational representing the ratio of numerator divided by denominator, with optional normalization. |
|
Rational(Integral numerator,
Integral denominator,
java.lang.String identifier)
Constructs an identified Rational representing the ratio of numerator divided by denominator. |
|
Rational(Integral numerator,
java.lang.String identifier)
Constructs an identified Rational representing the ratio of numerator divided by denominator, with optional normalization. |
protected |
Rational(Rational source)
Constructor to make a copy of a Rational object. |
|
Rational(java.lang.String string)
Secondary constructor to create a Rational from a String. |
| Method Summary | |
(package private) Rational |
absRational()
Method to yield the absolute (unsigned) value of this as a Rational. |
void |
add(BaseNumber that)
MUTATING Instance method to add another Arithmetical into this object. |
protected void |
addAbsError(double absBound,
int model)
This method is used to add in an intrinsic error bound. |
protected void |
addTops(Rational other)
|
Trigonometrical |
arctanX2()
Method to evaluate the arctangent function. |
java.lang.String |
audit(java.lang.String label)
Method to return a detailed string from an arithmetical object for debugging purposes. |
java.lang.Object |
clone()
Creates and returns a deep copy of this object. |
int |
compareTo(Integral val)
Compares this Rational with the specified Integral. |
int |
compareTo(Rational val)
Compares this Rational with the specified Rational. |
protected int |
compareTo(Rational val,
boolean absolute)
Compares this Rational with the specified Rational. |
java.lang.String |
defaultIdentifier()
Method to yield a default string to identify this object in the event that it has no explicitly defined identifier. |
(package private) Rational |
differenceRational(Rational subtrahend)
Method to yield the difference of this less a BaseNumber (subtrahend). |
void |
divide(BaseNumber that)
MUTATING method to replace this by the sum of this and that |
double |
doubleValue()
Returns the value of the specified number as a double. |
Trigonometrical |
exp()
Method to evaluate the exponential function. |
protected void |
factor(Integral divisor)
MUTATING METHOD: Replaces value with (this / divisor). |
Divisible |
factored(double factor)
Method to yield the quotient of this divided by factor, and return it as the result. |
float |
floatValue()
Returns the value of the specified number as a float. |
(package private) Rational |
fold(Rational range)
Method to force this into a specific range. |
(package private) long |
getBottom()
Method to yield the denominator as a long. |
double |
getBound()
Method to get the relative bound of this Rational. |
double |
getBoundAbs()
Method to get the absolute bound of non-fuzzy value. |
protected BaseNumber |
getDenominator()
Method to access the denominator of this Rational object. |
protected Integral |
getDenominatorAsIntegral()
Method to access the denominator of this Rational object. |
double |
getEstimate()
Method to get the current estimate of an arithmetical value. |
int |
getModel()
Method to get the error distribution model of this non-fuzzy object. |
protected BaseNumber |
getNumerator()
Method to access the numerator of this Rational object. |
protected Integral |
getNumeratorAsIntegral()
Method to access the numerator of this Rational object. |
(package private) long |
getTop()
Method to yield the numerator as a long. |
Rational |
half()
Method to yield half the value of this. |
int |
hashCode()
Method to determine a hash code for this object. |
int |
intValue()
Method to yield the equivalent integer value for this object. |
Divisible |
inverse()
Method to yield the reciprocal of this and return it as the result. |
(package private) Rational |
inverseRational()
|
void |
invert()
MUTATING Instance method to invert this (i.e. |
boolean |
isExact()
Method to determine if the quantity represented is non-fuzzy; |
boolean |
isInfinite()
Method to determine if an arithmetical object is infinite. |
boolean |
isInteger()
Method determines if it is safe and appropriate to convert this arithmetical object into BigInteger. |
(package private) boolean |
isIntFuzzy()
This method is used to determine if the numerical value of this is convertible to a int, without regard to the precision. |
(package private) boolean |
isNaN()
Method to determine if this Rational is "not a number". |
boolean |
isNormal()
Method to determine if this instance is already normalized. |
boolean |
isUnity()
Method to determine if this arithmetical object has the exact value of 1. |
Trigonometrical |
log()
Method to evaluate the natural log function. |
long |
longValue()
Method to yield the equivalent integer value for this object. |
(package private) long |
longValue(double tolerance)
Method to yield the long value of this object. |
(package private) double |
magnitude()
Method to yield the magnitude of this Rational as a double. |
static void |
main(java.lang.String[] args)
Main method for testing this class. |
Presentable |
makePresentableInstance(Presentation presentation)
Instance method to convert a Presentation into a Presentable. |
protected BaseNumber |
minus()
Method to yield a copy of this but with the sign changed. |
(package private) Rational |
minusRational()
Method to yield a copy of this but with the sign changed. |
(package private) Rational |
modulo(long x)
Method to return the value of this modulo x |
void |
multiply(BaseNumber that)
MUTATING Instance method to multiply another Arithmetical into this object. |
protected void |
multiplyTopAndBottom(BaseNumber factor)
MUTATING method to multiply the top and bottom of a rational equally. |
void |
negate()
MUTATING Instance method to negate this. |
void |
normalize()
MUTATING instance method to remove any common factors from top and bottom. |
(package private) Rational |
normalizeToBigDecimal(double tolerance)
Normalize this such that the denominator is a power of ten AND the value of the result differs from the value of this by not more than the tolerance. |
(package private) Rational |
normalizeToInt(double tolerance)
Normalize this Rational so that the result: a) has a denominator unity and b) approximates this in value, to within tolerance. |
static Rational |
Parse(NumberPresentation presentation,
java.lang.String identifier)
Translates the NumberPresentation representation into a new Rational. |
static Presentable |
Parse(Presentation presentation)
Create a Rational from a Presentation and return it as a Presentable. |
protected BaseNumber |
pow(double power)
Method to yield this raised to a double-precision power. |
protected BaseNumber |
pow(int power)
Method to raise this to the power power return the result. |
Presentation |
present(AttrMap attributes)
Convert this Presentable object into a Presentation, according to the set of attributes provided. |
(package private) Rational |
productRational(Rational multiplicand)
Method to multiply multiplicand to this and return their product as the result. |
Divisible |
quotient(BaseNumber divisor)
Method to divide this by multiplicand and return the quotient as the result. |
(package private) Rational |
quotientRational(Rational that)
|
void |
raiseToPower(int power)
MUTATING Instance method to raise this to power x. |
(package private) Rational |
root(int p)
method root: to yield an exact (integer) Rational for the root of a positive integral Rational. |
void |
scale(double factor)
MUTATING Instance method to multiply this by a (double) scale factor |
void |
scale(long factor)
MUTATING Instance method to multiply this by a scale factor. |
protected BaseNumber |
scaled(long multiplicand)
Method to multiply multiplicand by this and return their product as the result. |
void |
setBound(double bound)
MUTATING Method to set the relative bound of fuzzy value. |
protected void |
setBoundAbs(double bound)
MUTATING Method to set the absolute bound of fuzzy value. |
void |
setModel(int model)
MUTATING Method to set the error distribution model. |
int |
signum()
Method to find the sign of the magnitude of this arithmetical object. |
(package private) Rational |
squareRational()
Method to return the Rational formed my multiplying this by itself. |
void |
subtract(Rational that)
MUTATING method to replace this by the difference of this and that |
(package private) Rational |
sumRational(Rational addend)
Method to add addend to this and return their sum as the result. |
Trigonometrical |
tan_theta_2()
Method to evaluate the tangent function. |
(package private) void |
timesTenToPower(int power)
Package-protected MUTATING method to multiply this by a power of ten. |
(package private) Approximation |
toApproximation()
Method to convert this Rational into the appropriate Approximation. |
Integral |
toIntegral()
Method to present a Rational as an Integral number. |
java.lang.String |
toString()
Method to yield a string representing this Rational exactly. |
(package private) java.lang.String |
toString(double tolerance)
Method to determine a suitable string to represent this Rational, such that the resulting string is precise within tolerance. |
void |
updateEstimate()
MUTATING method to update the current estimate. |
static Rational |
valueOf(BaseNumber number)
Factory method to create a Rational from a BaseNumber or, if number is Rational, then to make a copy. |
(package private) static Rational |
valueOf(java.math.BigInteger integer,
java.math.BigInteger fraction,
int places)
Factory method to create a (decimal) Rational from two (big) integers. |
static Rational |
valueOf(double value)
Factory method to create a Rational from an exact double value. |
static Rational |
valueOf(double value,
boolean exact)
Factory method to create a Rational from a double value, that may or not be "exact". |
static Rational |
valueOf(double value,
double bound,
int model)
Factory method to create a Rational from a double value, given an indication of precision. |
static Rational |
valueOf(double value,
double bound,
int model,
java.lang.String identifier)
Factory method to create a Rational from a double value, given an indication of precision. |
static Rational |
valueOf(double value,
int precision,
java.lang.String identifier)
Factory method to create a Rational from a double value, given an indication of precision. |
static Rational |
valueOf(double value,
java.lang.String identifier)
Factory method to create a Rational from a double value, using standard double precision and with an explicit identifier. |
static Rational |
valueOf(float value)
Factory method to create a Rational from a float value, given an explicit identifier. |
static Rational |
valueOf(float value,
java.lang.String identifier)
Factory method to create a Rational from a float value without an explicit identifier. |
static Rational |
valueOf(Presentation presentation)
Convert Presentation presentation into a Rational. |
static BaseNumber |
valueOf(java.lang.String string)
Convenience factory method to create a new Rational instance from a value string and an implicit identifier (the value string itself). |
static BaseNumber |
valueOf(java.lang.String string,
java.lang.String id)
Convenience factory method to create a new Rational instance from a value string and an explicit identifier. |
(package private) static Rational |
valueOfExponent(int exponent)
Factory method to create a Rational which is equal to 10^exponent. |
(package private) static Rational |
valueOfExponent(int exponent,
int radix)
Factory method to create a Rational which is equal to radix^exponent. |
(package private) static Rational |
valueOfExponent(java.lang.String exponentStr,
int radix)
Factory method to create a Rational which is equal to the multiplier represented by an exponent string. |
| Methods inherited from class com.rubecula.jquantity.MutableNumber |
assertMutable, factored, forcePositive, getIdentifier, getIdentifier, isLong, isMutable, product, setConstant, setIdentifier, setIdentifierPost, setIdentifierPre, setIdentifierPrePost, sum, test |
| Methods inherited from class com.rubecula.jquantity.BaseNumber |
abs, bestModel, BestModel, byteValue, characteristic, Characteristic, difference, impartFuzziness, isEqual, isUncertain, isZero, shortValue, valueOfLog10, Wrap |
| Methods inherited from class com.rubecula.jquantity.Item |
audit, audit, compareTo, Debug, getClassNameShort, getType, IsDebug, present, SetDebug, test, test |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface com.rubecula.jquantity.Mutable |
isMutable |
| Methods inherited from interface com.rubecula.util.Auditable |
audit, audit |
| Field Detail |
public static final Rational $1
public static final Rational $0
public static final Rational $10
public static final Rational $2
public static final Rational $1_2
public static final Rational $Infinity
public static final Rational $E
public static final Rational $Pi
protected BaseNumber _Numerator
protected BaseNumber _Denominator
protected double _Estimate
static final Rational $3
static final Rational $6
static final Rational $12
static final Rational $NaN
static final Rational $_Pi_2
static final Rational $_Pi_4
public static final Rational $_Log10_E
static final java.lang.String $S_Rt2
static final java.lang.String $S_Rt3
static final java.lang.String $S_Rt5
static final Rational $Rt2
static final Rational $Rt3
static final Rational $Rt5
static final Rational $_Tan15Deg
static final Rational $_Tan22_5Deg
static final Rational $_Tan30Deg
static final Rational $_c
static final Rational $_degR
static final Rational $_degF
| Constructor Detail |
public Rational()
public Rational(java.lang.String string)
throws PresentationException
string - the String from which to create a Rationa.
PresentationException - if the string cannot be parsed as a
Rational object.
public Rational(Integral numerator,
Integral denominator,
java.lang.String identifier)
numerator - the numerator (top) of the ratio.denominator - the denominator (bottom) of the ratio.identifier - the identifier to be used to identify this object.
public Rational(Integral numerator,
Integral denominator)
numerator - Integral which is the numerator (top) of the ratiodenominator - Integral which is the denominator (bottom) of the ratio
public Rational(Integral numerator,
java.lang.String identifier)
numerator - the numerator (top) of the ratioidentifier - the identifier to be used to identify this object.public Rational(Integral value)
value - the numerator (top) of the ratio.
protected Rational(java.math.BigDecimal x,
java.lang.String identifier)
x - a BigDecimal number which is to be widened into a Rationa.identifier - the identifier for the new instance.
protected Rational(Integral numerator,
Integral denominator,
boolean normalize,
java.lang.String identifier)
numerator - the numerator (top) of the ratio,
which must be an instance of either Manifest or WholeNumber.denominator - the denominator (bottom) of the ratio,
which must be an instance of either Manifest or WholeNumber.normalize - normally true (only set to false if you really know what
you're doing).identifier - the identifier to be used to identify this object (or null).
RationalException - if either numerator or denominator is not an
instance of either Manifest or WholeNumber.
protected Rational(Integral numerator,
Integral denominator,
boolean normalize)
numerator - the numerator (top) of the ratio.denominator - the denominator (bottom) of the ratio.normalize - normally true (only set to false if you really know what
you're doing)Rational(java.math.BigDecimal x)
protected Rational(Rational source)
source - the object to copy.| Method Detail |
public static Rational Parse(NumberPresentation presentation,
java.lang.String identifier)
throws PresentationException
presentation - NumberPresentation.identifier - A string with which to identify this Rational.
PresentationException - if the presentation cannot be parsed as a
Rational object.public static Rational valueOf(BaseNumber number)
number - the value to be widened into a Rational.
public static BaseNumber valueOf(java.lang.String string,
java.lang.String id)
throws PresentationException
string - a representation of a NumberPresentation.id - Identifier for new Rational.
PresentationException - if the string cannot be parsed as a
Rational object.NumberPresentation.NumberPresentation(string),
#Parse(NumberPresentation)
public static BaseNumber valueOf(java.lang.String string)
throws PresentationException
string - a representation of a NumberPresentation.
PresentationException - if the string cannot be parsed as a
Rational object.valueOf(String,String)
public Presentable makePresentableInstance(Presentation presentation)
throws PresentationException
makePresentableInstance in interface Presentablepresentation - of a number to be converted into a Presentable number.
PresentationException - if presentation cannot be parsed appropriately.
public static Presentable Parse(Presentation presentation)
throws PresentationException
presentation - A presentation which should be parsed to form a Presentable.
PresentationException - if the presentation cannot be parsed as a
Presentable object.public java.lang.Object clone()
clone in class MutableNumberRationalException - : Rational not Cloneable (should be impossible)Cloneablepublic double getBoundAbs()
getBoundAbs in class BaseNumberpublic double getBound()
getBound in interface FuzzygetBound in class BaseNumberpublic int getModel()
getModel in interface FuzzygetModel in class BaseNumberpublic boolean isExact()
isExact in interface FuzzyisExact in class BaseNumberpublic int intValue()
intValue in class BaseNumberpublic long longValue()
longValue in class BaseNumberpublic float floatValue()
float.
This may involve rounding.
floatValue in class BaseNumberfloat.public double doubleValue()
double.
This may involve rounding.
doubleValue in class BaseNumberdouble.public int signum()
signum in interface Arithmeticalpublic boolean isInteger()
isInteger in interface Arithmeticalpublic boolean isUnity()
isUnity in interface Arithmeticalpublic boolean isInfinite()
isInfinite in interface Arithmeticalpublic void raiseToPower(int power)
Arithmutable
raiseToPower in interface Arithmutablepower - the number of times this should be multiplied by itself.public void scale(long factor)
Arithmutable
scale in interface Arithmutablefactor - the scale factor.public void negate()
Arithmutable
negate in interface Arithmutablepublic void add(BaseNumber that)
Arithmutable
add in interface Arithmutablethat - the number to add to this.
public void multiply(BaseNumber that)
throws InvalidOperandException
Arithmutable
multiply in interface Arithmutablethat - the number by which this is to be multiplied.
InvalidOperandException - operands are not compatible for the multiply
operation.public void scale(double factor)
scale in class DivisibleMutablefactor - double the scale factorpublic void invert()
invert in class DivisibleMutable
public void divide(BaseNumber that)
throws InvalidOperandException
divide in class DivisibleMutablethat - the value to be divided into this
InvalidOperandException - if that is not compatible with the multiply operation.public Divisible inverse()
inverse in interface Divisible
public Divisible quotient(BaseNumber divisor)
throws InvalidOperandException
quotient in interface Divisibledivisor - the number to multiply by this.
InvalidOperandException - if that is not compatible with the multiply operation.public Divisible factored(double factor)
factored in interface Divisiblefactor - the scale factor.
public Trigonometrical exp()
log().
exp in interface Trigonometricalpublic Trigonometrical log()
exp().
log in interface Trigonometricalpublic Trigonometrical arctanX2()
tan_theta_2().
arctanX2 in interface Trigonometricalpublic Trigonometrical tan_theta_2()
arctanX2().
tan_theta_2 in interface Trigonometricalprotected void setBoundAbs(double bound)
bound - the absolute boundpublic void setBound(double bound)
setBound in interface FuzzyMutablebound - the relative boundpublic void setModel(int model)
setModel in interface FuzzyMutablemodel - the distribution model:
$DistNone, $DistUniform or $DistGaussianpublic void updateEstimate()
updateEstimate in interface Estimablepublic double getEstimate()
getEstimate in interface Estimablepublic Integral toIntegral()
toIntegral in class MutableNumberfinal Rational minusRational()
final Rational sumRational(Rational addend)
addend - the number to add to this.
final Rational differenceRational(Rational subtrahend)
subtrahend - the number to subtract from this.
final Rational productRational(Rational multiplicand)
multiplicand - the number to add to this.
final Rational quotientRational(Rational that)
final Rational inverseRational()
protected final BaseNumber getDenominator()
protected final BaseNumber getNumerator()
protected final Integral getDenominatorAsIntegral()
protected final Integral getNumeratorAsIntegral()
protected BaseNumber minus()
minus in class BaseNumberprotected BaseNumber scaled(long multiplicand)
scaled in class BaseNumbermultiplicand - the number to multiply this by.
protected BaseNumber pow(int power)
pow in class BaseNumberpower - the exponent for this.
protected void factor(Integral divisor)
factor in class MutableNumberdivisor - value by which this WholeNumber is to be divided.BaseNumber.factor(Integral)
static Rational valueOfExponent(int exponent,
int radix)
exponent - the power to which radix is to be raised.radix - the base of the number system.
static Rational valueOfExponent(int exponent)
exponent - the power to which radix is to be raised.
static Rational valueOfExponent(java.lang.String exponentStr,
int radix)
exponentStr - the power to which radix is to be raised, as a string.radix - the base of the number system in which exponentStr is to
be interpreted and also the number to be raised by the appropriate power.
public static Rational valueOf(double value,
int precision,
java.lang.String identifier)
value - double: the value to convert to Rational.precision - int: the number of significant figures (approx.).identifier - String: the identifier to be used to identify this object (or null).
public static Rational valueOf(double value,
double bound,
int model,
java.lang.String identifier)
value - the value to convert to Rational.bound - an explicit value for the relative error bound.model - the error bound model to be used.identifier - String: the identifier to be used to identify this object (or null).
valueOf(double,int,String)
public static Rational valueOf(double value,
double bound,
int model)
value - the value to convert to Rational.bound - an explicit value for the relative error bound.model - the error bound model to be used.
valueOf(double,double,int)
public static Rational valueOf(double value,
java.lang.String identifier)
value - the value to convert to Rational.identifier - the explicit identifier for this value.
valueOf(double,double,int)
public static Rational valueOf(double value,
boolean exact)
value - double: the value to convert to Rational.exact - an indication of whether the result should be be considered exact.
valueOf(double,int,String)public static Rational valueOf(double value)
value - the value as a double.
valueOf(double,boolean)
public static Rational valueOf(float value,
java.lang.String identifier)
value - the value to convert to Rational.identifier - String: the identifier to be used to identify this object (or null).
valueOf(double,int,String)public static Rational valueOf(float value)
value - the value to convert to Rational.
valueOf(float,String)
static Rational valueOf(java.math.BigInteger integer,
java.math.BigInteger fraction,
int places)
integer - BigInteger : the integer part.fraction - BigInteger : the fractional part.places - int : the number of decimal places for fractional part.
protected void multiplyTopAndBottom(BaseNumber factor)
factor - the number by which top and bottom will be multiplied.protected void addTops(Rational other)
public void subtract(Rational that)
that - Rational the value to be subtracted from thisRational absRational()
BaseNumber.abs()public java.lang.String defaultIdentifier()
defaultIdentifier in class MutableNumberpublic java.lang.String audit(java.lang.String label)
audit in interface Auditablelabel - String: the label to associate with the data
public Rational half()
Rational modulo(long x)
x - the divisor for the modulo operation.
Rational fold(Rational range)
range - defines the range (-limit < magnitude <= +limit).
long getTop()
final long getBottom()
public int hashCode()
hashCode in class java.lang.Objectboolean isNaN()
Rational normalizeToInt(double tolerance)
throws com.rubecula.jquantity.Rational.RationalException
tolerance - the acceptable error in value of the result.
RationalException - if no acceptable result can be found.
com.rubecula.jquantity.Rational.RationalException
Rational normalizeToBigDecimal(double tolerance)
throws com.rubecula.jquantity.Rational.RationalException
tolerance - the acceptable discrepancy in values (may be zero).
RationalException - An "equivalent" instance cannot be created.
com.rubecula.jquantity.Rational.RationalExceptionpublic void normalize()
normalize in interface Normalizablepublic boolean isNormal()
isNormal in interface Normalizableprotected BaseNumber pow(double power)
power - the power with which to raise this.
Rational root(int p)
throws com.rubecula.jquantity.Rational.RationalException
p - the inverse of the power to which this will be raised.
RationalException
com.rubecula.jquantity.Rational.RationalExceptionRational squareRational()
public java.lang.String toString()
toString in class ItemtoString(double)final java.lang.String toString(double tolerance)
tolerance - the maximum discrepancy between the value represented by
the result and this.
#present(double)
public Presentation present(AttrMap attributes)
throws PresentationException
present in interface Presentableattributes - a map of the required attributes for the presentation.
Supported attributes include:
PresentationException - if this object cannot be presented
with the given attributes.
public static Rational valueOf(Presentation presentation)
throws PresentationException
presentation - a Presentation.
PresentationException - if presentation presentation cannot
be parsed as a Rational object.Approximation toApproximation()
long longValue(double tolerance)
throws com.rubecula.jquantity.Rational.RationalException
tolerance - The tolerance within which we don't mind losing precision
as we perform this conversion.
RationalException
com.rubecula.jquantity.Rational.RationalExceptionvoid timesTenToPower(int power)
power - the power of ten by which to multiply this.double magnitude()
doubleValue()boolean isIntFuzzy()
protected void addAbsError(double absBound,
int model)
absBound - the (intrinsic) error bound which should be added in to
any existing error bound of this.model - the model of the intrinsic error.
protected int compareTo(Rational val,
boolean absolute)
val - Rational to which this Rational is to be compared.absolute - Whether to take the difference (if true) or the quotient
(if false) when comparing the values.
public int compareTo(Rational val)
val - Rational to which this Rational is to be compared.
public int compareTo(Integral val)
val - Rational to which this Rational is to be compared.
public static void main(java.lang.String[] args)
args - String[] : the command line options.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||