units / org.apache.tuweni.units.bigints / BaseUInt256Value

BaseUInt256Value

abstract class BaseUInt256Value<T : UInt256Value<T>> : UInt256Value<T> (source)

Base class for UInt256Value.

This class is abstract as it is not meant to be used directly, but it has no abstract methods. As mentioned in UInt256Value, this is used to create strongly-typed type aliases of UInt256. 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 UInt256Value, but also adds a few operations that take a UInt256 directly, for instance #multiply(UInt256). The rational is that multiplying a given quantity of something by a "raw" number is always meaningful, and return a new quantity of the same thing.

Parameters

- The concrete type of the value.

Functions

add

open fun add(value: T): T
open fun add(value: Long): Topen fun add(value: UInt256): T

Returns a value that is (this + value).

addMod

open fun addMod(value: T, modulus: UInt256): T
open fun addMod(value: Long, modulus: UInt256): T
open fun addMod(value: Long, modulus: Long): Topen fun addMod(value: UInt256, modulus: UInt256): T

Returns a value equivalent to ((this + value) mod modulus).

compareTo

open fun compareTo(other: T): Intopen fun compareTo(other: UInt256): Int

Compare two UInt256 values.

divide

open fun divide(value: T): T
open fun divide(value: Long): Topen fun divide(value: UInt256): T

Returns a value that is (this / value).

divideCeil

open fun divideCeil(value: T): T
open fun divideCeil(value: Long): Topen fun divideCeil(value: UInt256): T

Returns a value that is (this / value).

equals

open fun equals(other: Any?): Boolean

hashCode

open fun hashCode(): Int

mod

open fun mod(modulus: UInt256): T
open fun mod(modulus: Long): T

mod0

open fun mod0(modulus: UInt256): T
open fun mod0(modulus: Long): T

multiply

open fun multiply(value: T): T
open fun multiply(value: Long): Topen fun multiply(value: UInt256): T

Returns a value that is (this * value).

multiplyMod

open fun multiplyMod(value: T, modulus: UInt256): T
open fun multiplyMod(value: Long, modulus: UInt256): T
open fun multiplyMod(value: Long, modulus: Long): Topen fun multiplyMod(value: UInt256, modulus: UInt256): T

Returns a value that is ((this * value) mod modulus).

pow

open fun pow(exponent: UInt256): T
open fun pow(exponent: Long): T

subtract

open fun subtract(value: T): T
open fun subtract(value: Long): Topen fun subtract(value: UInt256): T

Returns a value that is (this - value).

toBytes

open fun toBytes(): Bytes32

toMinimalBytes

open fun toMinimalBytes(): Bytes

toString

open fun toString(): String

toUInt256

open fun toUInt256(): UInt256

Inherited Functions

addExact

open fun addExact(value: T): T
open fun addExact(value: Long): T

Returns a value that is (this + value).

bitLength

open fun bitLength(): Int

fitsInt

open fun fitsInt(): Boolean

fitsLong

open fun fitsLong(): Boolean

intValue

open fun intValue(): Int

isZero

open fun isZero(): Boolean

numberOfLeadingZeros

open fun numberOfLeadingZeros(): Int

plus

open fun plus(value: T): T
open fun plus(value: Long): T

Returns a value that is (this + value).

This notation can be used in Kotlin with the + operator.

subtractExact

open fun subtractExact(value: T): T
open fun subtractExact(value: Long): T

Returns a value that is (this - value).

toBigInteger

open fun toBigInteger(): BigInteger

toHexString

open fun toHexString(): String

This value represented as an hexadecimal string.

Note that this representation includes all the 32 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 #toShortHexString.

toLong

open fun toLong(): Long

toShortHexString

open fun toShortHexString(): String

Inheritors

Wei

class Wei : BaseUInt256Value<Wei>

A unit measure of Wei as used by the Ethereum VM.