Package convex.core.data.prim
Class CVMDouble
java.lang.Object
convex.core.data.AObject
convex.core.data.ACell
convex.core.data.prim.APrimitive
convex.core.data.prim.CVMDouble
- All Implemented Interfaces:
INumeric
,IValidated
,IWriteable
Class for CVM double floating-point values.
Follows the Java standard / IEEE 784 spec.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic CVMDouble
static CVMDouble
static CVMDouble
static CVMDouble
static CVMDouble
static CVMDouble
static CVMDouble
Fields inherited from class convex.core.data.ACell
cachedRef, EMPTY_ARRAY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic CVMDouble
create(double value)
double
int
encode(byte[] bs, int pos)
Writes this Cell's encoding to a byte array, including a tag byte which will be written firstint
encodeRaw(byte[] bs, int pos)
Writes this Cell's encoding to a byte array, excluding the tag byteint
Estimate the encoded data size for this Cell.byte
getTag()
Gets the tag byte for this cell.getType()
Gets the most specific known runtime Type for this Cell.long
Class<?>
Gets the numeric type that should be used as for calculationsstatic CVMDouble
void
print(StringBuilder sb)
Prints this Object to a readable String Representationsignum()
Gets the signum of this numerical value.toDouble()
toLong()
toString()
Returns the String representation of this Cell.void
Validates the local structure and invariants of this cell.Methods inherited from class convex.core.data.prim.APrimitive
calcMemorySize, createRef, getRefCount, isCanonical, isCVMValue, isEmbedded, toCanonical
Methods inherited from class convex.core.data.ACell
announce, announce, attachMemorySize, attachRef, cachedEncoding, cachedHash, createAnnounced, createEncoding, createPersisted, createPersisted, equals, equals, getChildRefs, getEncoding, getEncodingLength, getHash, getMemorySize, getRef, getRef, hashCode, updateRefs, validate, write
Methods inherited from class convex.core.data.AObject
attachEncoding, print
-
Field Details
-
ZERO
-
NEGATIVE_ZERO
-
ONE
-
MINUS_ONE
-
NaN
-
POSITIVE_INFINITY
-
NEGATIVE_INFINITY
-
-
Constructor Details
-
CVMDouble
public CVMDouble(double value)
-
-
Method Details
-
create
-
getType
Description copied from class:ACell
Gets the most specific known runtime Type for this Cell. -
longValue
public long longValue()- Specified by:
longValue
in classAPrimitive
- Returns:
- long value representing primitive
-
toLong
-
toDouble
-
signum
Description copied from interface:INumeric
Gets the signum of this numerical value. Will be -1, 0 or 1 for Longs, -1.0, 0.0 , 1.0 or ##NaN for doubles. -
estimatedEncodingSize
public int estimatedEncodingSize()Description copied from interface:IWriteable
Estimate the encoded data size for this Cell. Used for quickly sizing buffers. Implementations should try to return a size that is likely to contain the entire object when represented in binary format, including the tag byte.- Specified by:
estimatedEncodingSize
in interfaceIWriteable
- Returns:
- The estimated size for the binary representation of this object.
-
validateCell
Description copied from class:ACell
Validates the local structure and invariants of this cell. Called by validate() super implementation. Should validate directly contained data, but should not validate all other structure of this cell. In particular, should not traverse potentially missing child Refs.- Specified by:
validateCell
in classACell
- Throws:
InvalidDataException
- If the Cell is invalid
-
encode
public int encode(byte[] bs, int pos)Description copied from class:ACell
Writes this Cell's encoding to a byte array, including a tag byte which will be written first- Specified by:
encode
in interfaceIWriteable
- Specified by:
encode
in classACell
- Parameters:
bs
- A byte array to which to write the encodingpos
- The offset into the byte array- Returns:
- New position after writing
-
encodeRaw
public int encodeRaw(byte[] bs, int pos)Description copied from class:ACell
Writes this Cell's encoding to a byte array, excluding the tag byte -
toString
Description copied from class:ACell
Returns the String representation of this Cell. The String representation is intended to be a easy-to-read textual representation of the Cell's data content. -
print
Description copied from class:AObject
Prints this Object to a readable String Representation -
numericType
Description copied from interface:INumeric
Gets the numeric type that should be used as for calculations- Specified by:
numericType
in interfaceINumeric
- Returns:
- Double.class or Long.class, or null if not a numeric type
-
doubleValue
public double doubleValue()- Specified by:
doubleValue
in interfaceINumeric
- Specified by:
doubleValue
in classAPrimitive
- Returns:
- double value representing primitive
-
parse
-
getTag
public byte getTag()Description copied from class:ACell
Gets the tag byte for this cell. The tag byte is always written as the first byte of the Cell's Encoding -
toStandardNumber
- Specified by:
toStandardNumber
in interfaceINumeric
-