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, EMPTY_ARRAY -
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 for message writing.abstract 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 AIntegerSubtracts another integer from this integerSubtracts a second numeric value to this valueabstract AIntegerConverts this Cell to its canonical version.Converts this numeric value to the nearest integerMethods inherited from class convex.core.data.prim.ANumeric
abs, doubleValue, ensureLong, isZero, multiply, negate, numericType, signum, toDouble, toLongMethods inherited from class convex.core.data.prim.APrimitive
calcMemorySize, getRefCount, isCVMValue, isEmbedded, longValueMethods inherited from class convex.core.data.ACell
announce, announce, attachMemorySize, attachRef, cachedEncoding, cachedHash, createAnnounced, createEncoding, createPersisted, createPersisted, createRef, encode, encodeRaw, equals, equals, getCanonical, getChildRefs, getEncoding, getEncodingLength, getHash, getMemorySize, getRef, getRef, getTag, hashCode, isCompletelyEncoded, mark, mark, toCVMString, toString, updateRefs, validate, validateCell, writeMethods 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 for message writing. Non-canonical objects may be used on a temporary internal basis, they must always be converted to canonical representations for external use (e.g. Encoding).- Overrides:
isCanonicalin classAPrimitive- Returns:
- true if the object is in canonical format, false otherwise
-
toCanonical
Description copied from class:ACellConverts this Cell to its canonical version. Must return this Cell if already canonical, may be O(n) in size of value otherwise.- Overrides:
toCanonicalin classAPrimitive- Returns:
- Canonical version of Cell
-
inc
Increments this Integer- Returns:
- Incremented value
-
dec
Decrements this Integer- Returns:
- Decremented value
-
getType
Description copied from class:ACellGets the most specific known runtime Type for this Cell. -
parse
Parse an integer value as a canonical value- Parameters:
s- String to parse- Returns:
- AInteger instance, or null if not convertible
-
parse
Parse a value as a canonical integer- Parameters:
o- Object to parse- Returns:
- AInteger instance, or null if not convertible
-
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
Description copied from class:ANumericAdds a second numeric value to this value -
add
Adds another integer to this integer- Parameters:
a- Integer value to add- Returns:
- New integer
-
sub
Description copied from class:ANumericSubtracts a second numeric value to this value -
sub
Subtracts another integer from this integer- Parameters:
a- Integer value to subtract- Returns:
- New integer
-
big
Converts this integer to a Java BigInteger. WARNING: might be O(n)- Returns:
- Java BigInteger
-
toInteger
Description copied from class:ANumericConverts this numeric value to the nearest integer -
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
Create a canonical CVM integer representation of the given Java Number- Parameters:
value- Long value- Returns:
- AInteger instance
-
mod
Returns the modulus of this integer with a given integer base- Parameters:
base- Base of modulus operation- Returns:
- Modulus result
-
div
Divides this integer with a given denominator. Performs Euclidian division consistent with mod- Parameters:
base- Base of division- Returns:
- Division result
-
quot
Divides this integer with a given denominator. Performs division consistent with rem- Parameters:
divisor- Base of division- Returns:
- Division result
-
rem
Returns the remainder of dividing this integer with a given divisor- Parameters:
divisor- Base of division operation- Returns:
- Modulus result
-