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 AIntegerAdds another integer to this integerAdds a second numeric value to this valueabstract BigIntegerbig()Converts this integer to a Java BigInteger.abstract longNumber of bytes in minimal representation of this Integer.static AIntegercreate(long value) Create a canonical CVM integer representation of the given Java Longstatic AIntegerCreate a canonical CVM integer representation of the given Java Numberstatic AIntegercreate(BigInteger bi) Create a canonical CVM integer representation of the given Java BigIntegerabstract AIntegerdec()Decrements this Integerabstract AIntegerDivides this integer with a given denominator.getType()Gets the most specific known runtime Type for this Cell.abstract AIntegerinc()Increments this Integerabstract booleanReturns true if this Cell is in a canonical representation.abstract booleanisLong()Return true if this value is a valid 64-bit long integerabstract AIntegerReturns the modulus of this integer with a given integer basestatic AIntegerParse a value as a canonical integerstatic AIntegerParse an integer value as a canonical valueabstract AIntegerDivides this integer with a given denominator.abstract AIntegerReturns the remainder of dividing this integer with a given divisorabstract CVMLongsignum()Gets the signum of this numerical value.abstract AIntegerSubtracts another integer from this integerSubtracts a second numeric value to this valueabstract ABlobtoBlob()Converts this Integer value to Blob formabstract AIntegerConverts 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, toLongMethods inherited from class convex.core.data.prim.APrimitive
calcMemorySize, getRef, getRefCount, isCVMValue, isDataValue, isEmbedded, longValue, updateRefsMethods 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, validateCellMethods inherited from class convex.core.data.AObject
attachEncoding, print, print, printMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Comparable
compareToMethods inherited from interface convex.core.data.IWriteable
estimatedEncodingSize
-
Constructor Details
-
AInteger
public AInteger()
-
-
Method Details
-
isCanonical
public abstract boolean isCanonical()Description copied from class:ACellReturns 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:
isCanonicalin classAPrimitive- Returns:
- true if the object is in canonical format, false otherwise
-
toCanonical
Description copied from class:ACellConverts 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:
toCanonicalin 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
-