|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.rubecula.util.Item
com.rubecula.jquantity.BaseNumber
Abstract (scalar) numerical class from which to derive other concrete classes. Ideally, (if Java was 100% perfect and supported multiple inheritance of abstract classes) this class would inherit from both java.lang.Number AND Item. Instead, we just copy the Number code. // TODO Can we solve this problem by defining an inner class to handle Number methods? In addition to the Comparable, Auditable and Presentable properties of the Item base class, objects of this class have a numerical value, which "may be" fuzzy - that is they support the Fuzzy interface.
// TODO extend for dates.
Field Summary | |
private static long |
serialVersionUID
use serialVersionUID from JDK 1.0.2 for interoperability |
Fields inherited from class com.rubecula.util.Item |
JQUANTITY_TEST |
Fields inherited from interface com.rubecula.jquantity.Fuzzy |
$DistGaussian, $DistInvalid, $DistNone, $DistUniform, $Names |
Constructor Summary | |
BaseNumber()
|
Method Summary | |
protected BaseNumber |
abs()
Method to yield this or a copy with the sign changed, depending whether the value is positive or negative. |
int |
bestModel(Fuzzy that)
Method to help in combining distribution models. |
protected static int |
BestModel(int modelX,
int modelY)
Class method to help in combining distribution models. |
byte |
byteValue()
Returns the value of the specified number as a byte .
|
(package private) int |
characteristic()
Method to yield the characteristic of a BaseNumber. |
(package private) static int |
Characteristic(double x)
Package-scope class method to yield the characteristic of value x (regardless of sign). |
protected BaseNumber |
difference(BaseNumber subtrahend)
Method to yield the difference of this less a BaseNumber (subtrahend). |
abstract double |
doubleValue()
Returns the value of the specified number as a double .
|
abstract float |
floatValue()
Returns the value of the specified number as a float .
|
double |
getBound()
Method to get the relative bound of this non-fuzzy value; |
double |
getBoundAbs()
Method to get the absolute bound of this non-fuzzy value; |
int |
getModel()
Method to get the error distribution model of this non-fuzzy value. |
Presentation |
impartFuzziness(NumberPresentation presentation)
Method to impart a NumberPresentation presentation with appropriate fuzzy information and ensure that the resulting string value is properly rounded. |
abstract int |
intValue()
Returns the value of the specified number as an int .
|
boolean |
isEqual(BaseNumber other)
Method to determine effect equality with another BaseNumber. |
boolean |
isExact()
Method to return true for this non-fuzzy instance. |
boolean |
isUncertain()
Method to determine if this object is of uncertain value due to fuzziness. |
boolean |
isZero()
Method to make standard test against zero. |
abstract long |
longValue()
Returns the value of the specified number as a long .
|
protected abstract BaseNumber |
minus()
Method to yield a copy of this but with the sign changed. |
protected abstract BaseNumber |
pow(int power)
Method to raise this to the power power return the result. |
protected abstract BaseNumber |
product(BaseNumber multiplicand)
Method to multiply multiplicand by this and return their product as the result. |
protected abstract BaseNumber |
scaled(long factor)
Method to multiply multiplicand by this and return their product as the result. |
short |
shortValue()
Returns the value of the specified number as a short .
|
protected abstract BaseNumber |
sum(BaseNumber addend)
Method to add addend to this and return their sum as the result. |
static BaseNumber |
valueOf(java.lang.String string)
Factory method to create a BaseNumber from a String string, without an explicit identifier (the string itself is used as the id). |
static BaseNumber |
valueOf(java.lang.String string,
java.lang.String id)
Factory method to create a BaseNumber from a String string, optionally identified by id. |
(package private) static double |
valueOfLog10(double x)
Package-scope class method to yield the value of log[base 10] (x). |
Methods inherited from class com.rubecula.util.Item |
audit, audit, compareTo, Debug, getClassNameShort, getType, IsDebug, present, SetDebug, test, test, toString, Wrap |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.rubecula.jquantity.Arithmetical |
isInfinite, isInteger, isUnity, signum |
Methods inherited from interface com.rubecula.util.Auditable |
audit, audit, audit |
Methods inherited from interface com.rubecula.util.Identifiable |
getIdentifier |
Methods inherited from interface com.rubecula.util.Presentable |
makePresentableInstance, present |
Field Detail |
private static final long serialVersionUID
Constructor Detail |
public BaseNumber()
Method Detail |
public static BaseNumber valueOf(java.lang.String string, java.lang.String id) throws PresentationException
string
- String representation of the object to be constructed.id
- Identifier (may be null).
PresentationException
- if this method not overridden.PresentationException.PresentationException(String)
public static BaseNumber valueOf(java.lang.String string) throws PresentationException
string
- String representation of the object to be constructed.
PresentationException
- if the string cannot be parsed into the
an instance of the defining class.valueOf(String, String)
public abstract int intValue()
int
.
This may involve rounding or truncation.
int
.public abstract long longValue()
long
.
This may involve rounding or truncation.
long
.public abstract float floatValue()
float
.
This may involve rounding.
float
.public abstract double doubleValue()
double
.
This may involve rounding.
double
.public byte byteValue()
byte
.
This may involve rounding or truncation.
byte
.public short shortValue()
short
.
This may involve rounding or truncation.
short
.protected static int BestModel(int modelX, int modelY)
modelX
- the first model to combine.modelY
- the second model to combine.
Fuzzy.$DistGaussian
,
Fuzzy.$DistInvalid
,
Fuzzy.$DistNone
,
Fuzzy.$DistUniform
protected abstract BaseNumber minus()
Method to yield a copy of this but with the sign changed.
NOTE: it is a requirement of this method that the class of the result
is the same as the class of this so that the result can be safely
cast to the original class.
Note that this method is parallel but not congruent with the method of the same name defined in the Integral interface.
protected abstract BaseNumber sum(BaseNumber addend) throws InvalidOperandException
addend
- the number to add to this.
InvalidOperandException
- if the operands are incompatible.protected BaseNumber difference(BaseNumber subtrahend) throws InvalidOperandException
subtrahend
- the number to subtract from this.
InvalidOperandException
- if the operands are incompatible.sum(BaseNumber)
,
minus()
protected abstract BaseNumber product(BaseNumber multiplicand) throws InvalidOperandException
multiplicand
- the number to multiply by this.
InvalidOperandException
- if the operands are incompatible.protected abstract BaseNumber scaled(long factor)
factor
- the number to multiply by this.
protected abstract BaseNumber pow(int power)
power
- the exponent for this.
public double getBoundAbs()
getBound()
,
doubleValue()
,
Math.abs(double)
public double getBound()
getBound
in interface Fuzzy
public int getModel()
getModel
in interface Fuzzy
Fuzzy.$DistNone
public boolean isExact()
isExact
in interface Fuzzy
public Presentation impartFuzziness(NumberPresentation presentation) throws PresentationException
presentation
- the unfuzzy NumberPresentation.
PresentationException
isExact()
,
getBound()
,
NumberPresentation.makeFuzzy(int, double)
public boolean isUncertain()
isExact()
,
Arithmetical.signum()
,
getBound()
,
Double.isNaN(double)
protected final BaseNumber abs()
Arithmetical.signum()
,
minus()
public final boolean isZero()
isExact()
,
Arithmetical.signum()
,
isUncertain()
public final boolean isEqual(BaseNumber other)
other
- the number to compare.
Item.compareTo(Object)
public final int bestModel(Fuzzy that)
that
- the other model source.
isExact()
,
Fuzzy.getModel()
,
BestModel(int, int)
int characteristic()
JQuantityException
doubleValue()
,
Characteristic(double)
static int Characteristic(double x)
x
- the value whose characteristic is required.
JQuantityException
- if x is zero.Math.abs(double)
,
valueOfLog10(double)
,
Math.round(double)
,
Math.floor(double)
static double valueOfLog10(double x)
x
- the value whose log is required.
Math.log(double)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |