interface UInt384Value<T : UInt384Value<T>> : Comparable<T>
(source)
Represents a 384-bit (48 bytes) unsigned integer value.
A UInt384Value is an unsigned integer value stored with 48 bytes, so whose value can range between 0 and 2^384-1.
This interface defines operations for value types with a 384-bit precision range. The methods provided by this interface take parameters of the same type (and also long
. This provides type safety by ensuring calculations cannot mix different UInt384Value
types.
Where only a pure numerical 384-bit value is required, UInt384 should be used.
It is strongly advised to extend BaseUInt384Value rather than implementing this interface directly. Doing so provides type safety in that quantities of different units cannot be mixed accidentally.
- The concrete type of the value.
abstract fun add(value: T): T abstract fun add(value: Long): T
Returns a value that is |
|
open fun addExact(value: T): T open fun addExact(value: Long): T
Returns a value that is |
|
abstract fun addMod(value: T, modulus: UInt384): T abstract fun addMod(value: Long, modulus: UInt384): T abstract fun addMod(value: Long, modulus: Long): T
Returns a value equivalent to |
|
open fun bitLength(): Int |
|
abstract fun divide(value: T): T abstract fun divide(value: Long): T
Returns a value that is |
|
open fun fitsInt(): Boolean |
|
open fun fitsLong(): Boolean |
|
open fun intValue(): Int |
|
open fun isZero(): Boolean |
|
abstract fun mod(modulus: UInt384): T abstract fun mod(modulus: Long): T
Returns a value that is |
|
abstract fun multiply(value: T): T abstract fun multiply(value: Long): T
Returns a value that is |
|
abstract fun multiplyMod(value: T, modulus: UInt384): T abstract fun multiplyMod(value: Long, modulus: UInt384): T abstract fun multiplyMod(value: Long, modulus: Long): T
Returns a value that is |
|
open fun numberOfLeadingZeros(): Int |
|
abstract fun pow(exponent: UInt384): T
Returns a value that is This calculates an exponentiation over the modulus of Note that abstract fun pow(exponent: Long): T
Returns a value that is This calculates an exponentiation over the modulus of |
|
abstract fun subtract(value: T): T abstract fun subtract(value: Long): T
Returns a value that is |
|
open fun subtractExact(value: T): T open fun subtractExact(value: Long): T
Returns a value that is |
|
open fun toBigInteger(): BigInteger |
|
abstract fun toBytes(): Bytes48 |
|
open fun toHexString(): String
This value represented as an hexadecimal string. Note that this representation includes all the 48 underlying bytes, no matter what the integer actually represents (in other words, it can have many leading zeros). For a shorter representation that don't include leading zeros, use |
|
open fun toLong(): Long |
|
abstract fun toMinimalBytes(): Bytes |
|
open fun toShortHexString(): String |
|
abstract fun toUInt384(): UInt384
Convert this value to a UInt384. |
abstract class BaseUInt384Value<T : UInt384Value<T>> : UInt384Value<T>
Base class for UInt384Value. This class is abstract as it is not meant to be used directly, but it has no abstract methods. As mentioned in UInt384Value, this is used to create strongly-typed type aliases of UInt384. In other words, this allow to "tag" numbers with the unit of what they represent for the type-system, which can help clarity, but also forbid mixing numbers that are mean to be of different units (the strongly-typed part). This class implements UInt384Value, but also adds a few operations that take a UInt384 directly, for instance |
|
class UInt384 : UInt384Value<UInt384>
An unsigned 384-bit precision number. This is a raw UInt384Value - a 384-bit precision unsigned number of no particular unit. |