|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectptolemy.data.Token
ptolemy.data.ScalarToken
ptolemy.data.DoubleToken
public class DoubleToken
A token that contains a 64-bit signed mantissa, signed exponent double precision floating-point number (IEEE 754). This class handles overflow and underflow as does normal java arithmetic on doubles.
Note that a double cannot be losslessly converted to a long, and vice versa, as both have 64-bit representations in Java.
Token
,
Serialized Form
Red (cxh) |
Yellow (cxh) nil token, ONE, ZERO |
Field Summary | |
---|---|
private double |
_value
|
static DoubleToken |
NIL
A token that represents a missing value. |
static DoubleToken |
ONE
A DoubleToken with the value 1.0. |
static DoubleToken |
ZERO
A DoubleToken with the value 0.0. |
Fields inherited from class ptolemy.data.ScalarToken |
---|
_unitCategoryExponents |
Constructor Summary | |
---|---|
DoubleToken()
Construct a DoubleToken with value 0.0. |
|
DoubleToken(double value)
Construct a DoubleToken with the specified value. |
|
DoubleToken(java.lang.String init)
Construct a DoubleToken from the specified string. |
Method Summary | |
---|---|
protected ScalarToken |
_absolute()
Return a ScalarToken containing the absolute value of the value of this token. |
protected ScalarToken |
_add(ScalarToken rightArgument)
Return a new token whose value is the value of the argument Token added to the value of this Token. |
protected ScalarToken |
_bitwiseAnd(ScalarToken rightArgument)
Returns a token representing the bitwise AND of this token and the given token. |
protected ScalarToken |
_bitwiseNot()
Returns a token representing the bitwise NOT of this token. |
protected ScalarToken |
_bitwiseOr(ScalarToken rightArgument)
Returns a token representing the bitwise OR of this token and the given token. |
protected ScalarToken |
_bitwiseXor(ScalarToken rightArgument)
Returns a token representing the bitwise XOR of this token and the given token. |
protected ScalarToken |
_divide(ScalarToken divisor)
Return a new token whose value is the value of this token divided by the value of the argument token. |
protected BooleanToken |
_isCloseTo(ScalarToken rightArgument,
double epsilon)
Test that the value of this token is close to the first argument, where "close" means that the distance between their values is less than or equal to the second argument. |
protected BooleanToken |
_isLessThan(ScalarToken rightArgument)
Test for ordering of the values of this Token and the argument Token. |
protected ScalarToken |
_modulo(ScalarToken rightArgument)
Return a new token whose value is the value of this token modulo the value of the argument token. |
protected ScalarToken |
_multiply(ScalarToken rightArgument)
Return a new token whose value is the value of this token multiplied by the value of the argument token. |
protected ScalarToken |
_subtract(ScalarToken rightArgument)
Return a new token whose value is the value of the argument token subtracted from the value of this token. |
Complex |
complexValue()
Return the value of this token as a Complex. |
static DoubleToken |
convert(Token token)
Convert the specified token into an instance of DoubleToken. |
double |
doubleValue()
Return the value in the token as a double. |
boolean |
equals(java.lang.Object object)
Return true if the argument's class is DoubleToken and it has the same values as this token. |
Type |
getType()
Return the type of this token. |
int |
hashCode()
Return a hash code value for this token. |
boolean |
isNil()
Return true if the token is nil, (aka null or missing). |
Token |
one()
Returns a DoubleToken with value 1.0. |
java.lang.String |
toString()
Return the value of this token as a string that can be parsed by the expression language to recover a token with the same value. |
Token |
zero()
Returns a DoubleToken with value 0.0. |
Methods inherited from class ptolemy.data.ScalarToken |
---|
_addCategoryExponents, _areUnitsEqual, _copyOfCategoryExponents, _isEqualTo, _isUnitless, _subtractCategoryExponents, absolute, add, addReverse, bitwiseAnd, bitwiseNot, bitwiseOr, bitwiseXor, byteValue, divide, divideReverse, fixValue, floatValue, intValue, inUnitsOf, isCloseTo, isEqualTo, isGreaterThan, isLessThan, leftShift, logicalRightShift, longValue, modulo, moduloReverse, multiply, multiplyReverse, rightShift, setUnitCategory, shortValue, subtract, subtractReverse, unitsString |
Methods inherited from class ptolemy.data.Token |
---|
isCloseTo, notSupportedConversionMessage, notSupportedIncomparableConversionMessage, notSupportedIncomparableMessage, notSupportedMessage, notSupportedNullNilStringMessage, pow, zeroReturnType |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final DoubleToken NIL
public static final DoubleToken ONE
public static final DoubleToken ZERO
private double _value
Constructor Detail |
---|
public DoubleToken()
public DoubleToken(double value)
value
- The specified value.public DoubleToken(java.lang.String init) throws IllegalActionException
init
- The initialization string, which is in a format
suitable for java.lang.Double.parseDouble(String).
IllegalActionException
- If the Token could not
be created with the given String.Method Detail |
---|
public Complex complexValue()
complexValue
in class ScalarToken
public static DoubleToken convert(Token token) throws IllegalActionException
NIL
is
returned. Otherwise, if the argument is below DoubleToken in
the type hierarchy, it is converted to an instance of
DoubleToken or one of the subclasses of DoubleToken and
returned. If none of the above condition is met, an exception
is thrown.
token
- The token to be converted to a DoubleToken.
IllegalActionException
- If the conversion
cannot be carried out.public double doubleValue()
doubleValue
in class ScalarToken
public boolean equals(java.lang.Object object)
equals
in class java.lang.Object
object
- An instance of Object.
public Type getType()
getType
in class ScalarToken
public int hashCode()
hashCode
in class java.lang.Object
public boolean isNil()
isNil
in class Token
NIL
token.public Token one()
one
in class Token
public java.lang.String toString()
Double.toString(token.doubleValue())
.
If this token has a unit, the return string also includes a unit
string produced by the unitsString() method in the super class.
toString
in class Token
ScalarToken.unitsString()
public Token zero()
zero
in class Token
protected ScalarToken _absolute()
_absolute
in class ScalarToken
protected ScalarToken _add(ScalarToken rightArgument)
_add
in class ScalarToken
rightArgument
- The token to add to this token.
protected ScalarToken _bitwiseAnd(ScalarToken rightArgument) throws IllegalActionException
_bitwiseAnd
in class ScalarToken
rightArgument
- The DoubleToken to bitwise AND with this one.
IllegalActionException
- Always thrown by this base class.protected ScalarToken _bitwiseNot() throws IllegalActionException
_bitwiseNot
in class ScalarToken
IllegalActionException
- Always thrown by this base class.protected ScalarToken _bitwiseOr(ScalarToken rightArgument) throws IllegalActionException
_bitwiseOr
in class ScalarToken
rightArgument
- The DoubleToken to bitwise OR with this one.
IllegalActionException
- Always thrown by this base class.protected ScalarToken _bitwiseXor(ScalarToken rightArgument) throws IllegalActionException
_bitwiseXor
in class ScalarToken
rightArgument
- The DoubleToken to bitwise XOR with this one.
IllegalActionException
- Always thrown by this base class.protected ScalarToken _divide(ScalarToken divisor)
_divide
in class ScalarToken
divisor
- The token to divide this token by.
protected BooleanToken _isCloseTo(ScalarToken rightArgument, double epsilon)
_isCloseTo
in class ScalarToken
rightArgument
- The token to compare to this token.epsilon
- The distance.
protected BooleanToken _isLessThan(ScalarToken rightArgument) throws IllegalActionException
_isLessThan
in class ScalarToken
rightArgument
- The token to compare to this token.
IllegalActionException
- If this method is not
supported by the derived class.protected ScalarToken _modulo(ScalarToken rightArgument)
_modulo
in class ScalarToken
rightArgument
- The token to modulo this token by.
protected ScalarToken _multiply(ScalarToken rightArgument)
_multiply
in class ScalarToken
rightArgument
- The token to multiply this token by.
protected ScalarToken _subtract(ScalarToken rightArgument)
_subtract
in class ScalarToken
rightArgument
- The token to subtract from this token.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |