|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--java.lang.Number
|
+--com.rubecula.jquantity.BaseNumber
|
+--com.rubecula.jquantity.MutableNumber
|
+--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 (for debugging purposes) |
protected BaseNumber |
_Numerator
_Numerator is the numerator of the rational quantity defined by this. |
(package private) static Rational |
$_2Pi
|
(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. |
(package private) static Rational |
$_Degree2Radian
|
(package private) static Rational |
$_Pi_12
|
(package private) static Rational |
$_Pi_2
|
(package private) static Rational |
$_Pi_4
|
(package private) static Rational |
$_Tan15Deg
2 - $Rt3. |
(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 java.math.BigInteger |
$MaxInt
Integer.MAX_VALUE. |
(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. |
|
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. |
|
Rational(java.lang.String string)
Secondary constructor to create a Rational from a String. |
| Method Summary | |
(package private) Rational |
absRational()
|
void |
add(BaseNumber that)
MUTATING Instance method to add another BaseNumber into this object. |
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. |
(package private) int |
characteristic()
|
(package private) static int |
Characteristic(java.math.BigDecimal x)
|
java.lang.Object |
clone()
Creates and returns a copy of this object. |
int |
compareTo(Integral val)
Compares this Rational with the specified Rational. |
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. |
(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. |
(package private) float |
expFloat(float factor)
|
protected void |
factor(Integral divisor)
MUTATING METHOD: Replaces value with (this / divisor). |
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()
|
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. |
(package private) static int |
GetExtraPrecisionDigits(int places,
int requiredExtrasLength,
Rational value,
double tolerance)
|
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) static int |
GetPrecisionPlaces(Rational upperBound,
Rational lowerBound,
double tolerance,
boolean gaussian)
|
(package private) long |
getTop()
|
Rational |
half()
|
int |
hashCode()
|
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 |
isNaN()
|
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 integer value of this object. |
(package private) double |
magnitude()
|
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)
|
(package private) float |
multFloat(float factor)
|
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)
|
static Rational |
Parse(NumberPresentation presentation,
java.lang.String identifier)
Translates the ValuePresentation representation of a FuzzInt in the specified radix into a FuzzInt. |
static Presentable |
Parse(Presentation presentation)
Create a FuzzInt from a Presentation and return it as a Presentable. |
(package private) int |
places()
|
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 power. |
(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. |
Divisible |
scaled(double multiplicand)
Method to multiply multiplicand by this and return their product as the result. |
protected BaseNumber |
scaled(long multiplicand)
Method to multiply multiplicand by this and return their product as the result. |
void |
setBound(double bound)
Method to set the relative bound of fuzzy value. |
protected void |
setBoundAbs(double bound)
Method to set the absolute bound of fuzzy value. |
void |
setModel(int model)
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()
|
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) static double |
TenToPower(int power)
|
(package private) void |
timesTenToPower(int power)
|
(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()
This is the default toString method for all BaseNumbers. |
(package private) java.lang.String |
toString(double 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.BigDecimal x)
|
protected static Rational |
valueOf(java.math.BigDecimal x,
java.lang.String identifier)
Factory method to create a Rational from a BigDecimal value and an identifier. |
(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)
|
static Rational |
valueOf(double value,
boolean 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)
|
static Rational |
valueOf(float value)
|
static Rational |
valueOf(float value,
java.lang.String identifier)
|
static Rational |
valueOf(Presentation presentation)
Convert Presentation presentation into a Rational. |
static Rational |
valueOf(java.lang.String string)
Translates the String representation of a FuzzInt in radix 10 to a FuzzInt. |
static Rational |
valueOf(java.lang.String string,
java.lang.String id)
Translates the String representation of a FuzzInt in radix 10 to a FuzzInt. |
(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. |
(package private) static double |
valueOfSquare(double x)
|
| Methods inherited from class com.rubecula.jquantity.MutableNumber |
factored, forcePositive, getIdentifier, isLong, product, setIdentifier, setIdentifierPost, setIdentifierPre, sum, test |
| Methods inherited from class com.rubecula.jquantity.BaseNumber |
abs, audit, audit, bestModel, BestModel, Characteristic, compareTo, difference, impartFuzziness, isEqual, isUncertain, isZero, present, test, test, valueOfLog10, Wrap |
| Methods inherited from class java.lang.Number |
byteValue, shortValue |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
| 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 $_2Pi
static final Rational $_Pi_2
static final Rational $_Pi_4
static final Rational $_Pi_12
static final Rational $_Degree2Radian
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 $_Tan30Deg
static final java.math.BigInteger $MaxInt
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(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)| Method Detail |
public static Rational Parse(NumberPresentation presentation,
java.lang.String identifier)
throws PresentationException
presentation - ValuePresentation representation of WholeNumber
followed by fuzzy information.identifier - A string with which to identify this Rational.
java.lang.NumberFormatException - val is not a valid representation
of a WholeNumber in the specified radix, or radix is
outside the range from Character.MIN_RADIX (2) to
Character.MAX_RADIX (36), inclusive.
PresentationException - if the presentation cannot be parsed as a
Rational object.Character.digit(char, int)public static Rational valueOf(BaseNumber number)
number - an integer (either WholeNumber or Manifest)
for which we require the (widened) Rational.
public static Rational valueOf(java.lang.String string,
java.lang.String id)
throws PresentationException
string - String representation of WholeNumber followed by fuzzy
information.id - Identifier for new Rational.
java.lang.NumberFormatException - val is not a valid representation
of a WholeNumber in the specified radix, or radix is
outside the range from Character.MIN_RADIX (2) to
Character.MAX_RADIX (36), inclusive.
PresentationException - if the string cannot be parsed as a
Rational object.Character.digit(char, int)
public static Rational valueOf(java.lang.String string)
throws PresentationException
string - String representation of WholeNumber followed by
fuzzy information.
java.lang.NumberFormatException - val is not a valid representation
of a WholeNumber in the specified radix, or radix is
outside the range from Character.MIN_RADIX (2) to
Character.MAX_RADIX (36), inclusive.
PresentationException - if the string cannot be parsed as a
Rational object.Character.digit(char, int)
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 java.lang.Numberpublic long longValue()
longValue in class java.lang.Numberpublic float floatValue()
float.
This may involve rounding.
floatValue in class java.lang.Numberfloat.public double doubleValue()
double.
This may involve rounding.
doubleValue in class java.lang.Numberdouble.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)
raiseToPower in interface Arithmutablepower - int the number of times this should be multiplied by itself.public void scale(long factor)
scale in interface Arithmutablefactor - the scale factor.public void negate()
negate in interface Arithmutablepublic void add(BaseNumber that)
add in interface Arithmutablethat - the addend.
public void multiply(BaseNumber that)
throws InvalidOperandException
multiply in interface Arithmutablethat - Arithmetical : the multiplicand.
InvalidOperandException - if that is not compatible with the multiply operation.public void scale(double factor)
factor - double the scale factorpublic void invert()
public void divide(BaseNumber that)
throws InvalidOperandException
that - 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 Trigonometrical exp()
exp in interface Trigonometricalpublic Trigonometrical log()
log in interface Trigonometricalpublic Trigonometrical arctanX2()
arctanX2 in interface Trigonometricalpublic Trigonometrical tan_theta_2()
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 static Rational valueOf(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 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.
public Divisible scaled(double multiplicand)
scaled in interface Divisiblemultiplicand - 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.
static Rational valueOf(java.math.BigDecimal x)
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 absolute error bound.model - the error bound model to be used.identifier - String: the identifier to be used to identify this object (or null).
public static Rational valueOf(double value,
double bound,
int model)
value - the value to convert to Rational.bound - an explicit value for the error bound.model - the error bound model to be used.
public static Rational valueOf(double value,
java.lang.String identifier)
public static Rational valueOf(double value,
boolean exact)
public static Rational valueOf(double value)
public static Rational valueOf(float value,
java.lang.String identifier)
public static Rational valueOf(float value)
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()
public 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)
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
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 Normalizable
int places()
throws com.rubecula.jquantity.Rational.RationalException
com.rubecula.jquantity.Rational.RationalException
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.RationalExceptionfloat multFloat(float factor)
float expFloat(float factor)
throws com.rubecula.jquantity.Rational.RationalException
com.rubecula.jquantity.Rational.RationalExceptionRational squareRational()
public java.lang.String toString()
BaseNumber
toString in class BaseNumberfinal java.lang.String toString(double tolerance)
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)
static double valueOfSquare(double x)
final double magnitude()
static double TenToPower(int power)
int characteristic()
throws com.rubecula.jquantity.Rational.RationalException
com.rubecula.jquantity.Rational.RationalException
static int Characteristic(java.math.BigDecimal x)
throws com.rubecula.jquantity.Rational.RationalException
com.rubecula.jquantity.Rational.RationalException
static int GetPrecisionPlaces(Rational upperBound,
Rational lowerBound,
double tolerance,
boolean gaussian)
throws com.rubecula.jquantity.Rational.RationalException
com.rubecula.jquantity.Rational.RationalException
static int GetExtraPrecisionDigits(int places,
int requiredExtrasLength,
Rational value,
double tolerance)
throws com.rubecula.jquantity.Rational.RationalException
com.rubecula.jquantity.Rational.RationalException
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 | |||||||||