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 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 for message writing.abstract 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 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, toDouble, toLong
Methods inherited from class convex.core.data.prim.APrimitive
calcMemorySize, getRefCount, isCVMValue, isEmbedded, longValue
Methods 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
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 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:
isCanonical
in classAPrimitive
- Returns:
- true if the object is in canonical format, false otherwise
-
toCanonical
Description copied from class:ACell
Converts this Cell to its canonical version. Must return this Cell if already canonical, may be O(n) in size of value otherwise.- Overrides:
toCanonical
in classAPrimitive
- Returns:
- Canonical version of Cell
-
inc
Increments this Integer- Returns:
- Incremented value
-
signum
Description copied from class:ANumeric
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. -
dec
Decrements this Integer- Returns:
- Decremented value
-
getType
Description copied from class:ACell
Gets 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:ANumeric
Adds 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:ANumeric
Subtracts 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:ANumeric
Converts 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
-
toBlob
Converts this Integer value to Blob form- Returns:
- minimal blob representing the integer value
-