tuweni / org.apache.tuweni.units.bigints / UInt64Value

UInt64Value

interface UInt64Value<T : UInt64Value<T>!> : Comparable<T> (source)

Represents a 64-bit (8 bytes) unsigned integer value.

A UInt64Value is an unsigned integer value whose value can range between 0 and 2^64-1.

This interface defines operations for value types with a 64-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 UInt64Value types.

Where only a pure numerical 64-bit value is required, UInt64 should be used.

It is strongly advised to extend BaseUInt64Value rather than implementing this interface directly. Doing so provides type safety in that quantities of different units cannot be mixed accidentally.

Functions

add

Returns a value that is (this + value).

abstract fun add(value: T): T
abstract fun add(value: Long): T

addExact

Returns a value that is (this + value).

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

addMod

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

abstract fun addMod(value: T, modulus: UInt64!): T
abstract fun addMod(value: Long, modulus: UInt64!): T
abstract fun addMod(value: Long, modulus: Long): T

bitLength

Returns the number of bits following and including the highest-order ("leftmost") one-bit

open fun bitLength(): Int

divide

Returns a value that is (this / value).

abstract fun divide(value: T): T
abstract fun divide(value: Long): T

fitsInt

Returns true if this value fits an int.

open fun fitsInt(): Boolean

fitsLong

Returns true if this value fits a long.

open fun fitsLong(): Boolean

intValue

Returns this value as an int.

open fun intValue(): Int

isZero

Returns true if this is 0.

open fun isZero(): Boolean

mod

Returns a value that is (this mod modulus).

abstract fun mod(modulus: UInt64!): T
abstract fun mod(modulus: Long): T

multiply

Returns a value that is (this * value).

abstract fun multiply(value: T): T
abstract fun multiply(value: Long): T

multiplyMod

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

abstract fun multiplyMod(value: T, modulus: UInt64!): T
abstract fun multiplyMod(value: Long, modulus: UInt64!): T
abstract fun multiplyMod(value: Long, modulus: Long): T

numberOfLeadingZeros

Returns the number of zero bits preceding the highest-order ("leftmost") one-bit

open fun numberOfLeadingZeros(): Int

pow

Returns a value that is (this<sup>exponent</sup> mod 2<sup>64</sup>)

abstract fun pow(exponent: UInt64!): T
abstract fun pow(exponent: Long): T

subtract

Returns a value that is (this - value).

abstract fun subtract(value: T): T
abstract fun subtract(value: Long): T

subtractExact

Returns a value that is (this - value).

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

toBigInteger

Returns this value as a BigInteger

open fun toBigInteger(): BigInteger!

toBytes

Returns the value as bytes.

abstract fun toBytes(): Bytes!

toHexString

This value represented as an hexadecimal string.

open fun toHexString(): String!

toLong

Returns this value as a long.

open fun toLong(): Long

toMinimalBytes

Returns the value as bytes without any leading zero bytes.

abstract fun toMinimalBytes(): Bytes!

toShortHexString

Returns this value represented as a minimal hexadecimal string (without any leading zero)

open fun toShortHexString(): String!

toUInt64

Convert this value to a UInt64.

abstract fun toUInt64(): UInt64!

Inheritors

BaseUInt64Value

Base class for UInt64Value.

abstract class BaseUInt64Value<T : UInt64Value<T>!> : UInt64Value<T>

UInt64

An unsigned 64-bit precision number. This is a raw UInt64Value - a 64-bit precision unsigned number of no particular unit.

class UInt64 : UInt64Value<UInt64!>