Package convex.core.data.prim
Class AInteger
java.lang.Object
convex.core.data.AObject
convex.core.data.ACell
convex.core.data.prim.APrimitive
convex.core.data.prim.ANumeric
convex.core.data.prim.AInteger
- All Implemented Interfaces:
IValidated
,IWriteable
,Comparable<ANumeric>
- Direct Known Subclasses:
CVMBigInteger
,CVMLong
Abstract base class for CVM Integer values
-
Field Summary
Fields inherited from class convex.core.data.ACell
cachedRef, memorySize
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract AInteger
Adds another integer to this integerAdds a second numeric value to this valueabstract BigInteger
big()
Converts this integer to a Java BigInteger.abstract long
Number of bytes in minimal representation of this Integer.static AInteger
create
(long value) Create a canonical CVM integer representation of the given Java Longstatic AInteger
Create a canonical CVM integer representation of the given Java Numberstatic AInteger
create
(BigInteger bi) Create a canonical CVM integer representation of the given Java BigIntegerabstract AInteger
dec()
Decrements this Integerabstract AInteger
Divides this integer with a given denominator.getType()
Gets the most specific known runtime Type for this Cell.abstract AInteger
inc()
Increments this Integerabstract boolean
Returns true if this Cell is in a canonical representation.abstract boolean
isLong()
Return true if this value is a valid 64-bit long integerabstract AInteger
Returns the modulus of this integer with a given integer basestatic AInteger
Parse a value as a canonical integerstatic AInteger
Parse an integer value as a canonical valueabstract AInteger
Divides this integer with a given denominator.abstract AInteger
Returns the remainder of dividing this integer with a given divisorabstract CVMLong
signum()
Gets the signum of this numerical value.abstract AInteger
Subtracts another integer from this integerSubtracts a second numeric value to this valueabstract ABlob
toBlob()
Converts this Integer value to Blob formabstract AInteger
Converts this Cell to a canonical version.Converts this numeric value to the nearest integerRaise the integer to the given powerMethods inherited from class convex.core.data.prim.ANumeric
abs, doubleValue, ensureLong, isZero, multiply, negate, numericType, toDouble, toLong
Methods inherited from class convex.core.data.prim.APrimitive
calcMemorySize, getRef, getRefCount, isCVMValue, isDataValue, isEmbedded, longValue, updateRefs
Methods inherited from class convex.core.data.ACell
attachMemorySize, attachRef, cachedEncoding, cachedHash, createEncoding, createRef, encode, encodeRaw, equals, equals, genericEquals, getCanonical, getChildRefs, getEncoding, getEncodingLength, getHash, getMemorySize, getMemorySize, getRef, getTag, hashCode, toCVMString, toString, validate, validateCell
Methods inherited from class convex.core.data.AObject
attachEncoding, print, print, print
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Comparable
compareTo
Methods inherited from interface convex.core.data.IWriteable
estimatedEncodingSize
-
Constructor Details
-
AInteger
public AInteger()
-
-
Method Details
-
isCanonical
public abstract boolean isCanonical()Description copied from class:ACell
Returns true if this Cell is in a canonical representation. Non-canonical objects may be used on a temporary internal basis, they should be converted to canonical representations for general purpose use.- Overrides:
isCanonical
in classAPrimitive
- Returns:
- true if the object is in canonical format, false otherwise
-
toCanonical
Description copied from class:ACell
Converts this Cell to a canonical version. Must return this Cell if already canonical, may be O(n) in size of value otherwise. Callers should usually use getCanonical(), which caches canonical instances once created- Overrides:
toCanonical
in classAPrimitive
- Returns:
- Canonical version of Cell
-
inc
-
signum
-
dec
-
getType
-
parse
-
parse
-
byteLength
public abstract long byteLength()Number of bytes in minimal representation of this Integer. Returns 0 if and only if the integer is zero.- Returns:
- Number of bytes
-
add
-
add
-
sub
-
sub
-
big
Converts this integer to a Java BigInteger. WARNING: might be O(n)- Returns:
- Java BigInteger
-
toInteger
-
create
Create a canonical CVM integer representation of the given Java BigInteger- Parameters:
bi
- BigInteger value- Returns:
- AInteger instance
-
create
Create a canonical CVM integer representation of the given Java Long- Parameters:
value
- Long value- Returns:
- AInteger instance
-
create
-
mod
-
div
-
quot
-
rem
-
toBlob
Converts this Integer value to Blob form- Returns:
- minimal blob representing the integer value
-
isLong
public abstract boolean isLong()Return true if this value is a valid 64-bit long integer- Returns:
- true if this integer fits in a 64-bit long
-
toPower
-