T - The concrete type of the value.public interface UInt256Value<T extends UInt256Value<T>> extends Comparable<T>
A UInt256Value is an unsigned integer value stored with 32 bytes, so whose
value can range between 0 and 2^256-1.
This interface defines operations for value types with a 256-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
UInt256Value types.
Where only a pure numerical 256-bit value is required, UInt256 should be used.
It is strongly advised to extend BaseUInt256Value rather than implementing this
interface directly. Doing so provides type safety in that quantities of different units
cannot be mixed accidentally.
| 限定符和类型 | 方法和说明 |
|---|---|
T |
add(long value)
Returns a value that is
(this + value). |
T |
add(T value)
Returns a value that is
(this + value). |
default T |
addExact(long value)
Returns a value that is
(this + value). |
default T |
addExact(T value)
Returns a value that is
(this + value). |
T |
addMod(long value,
long modulus)
Returns a value equivalent to
((this + value) mod modulus). |
T |
addMod(long value,
UInt256 modulus)
Returns a value equivalent to
((this + value) mod modulus). |
T |
addMod(T value,
UInt256 modulus)
Returns a value equivalent to
((this + value) mod modulus). |
default int |
bitLength()
Provides the number of bits following and including the highest-order ("leftmost")
one-bit in the binary representation of this value, or zero if all bits are zero.
|
T |
divide(long value)
Returns a value that is
(this / value). |
T |
divide(T value)
Returns a value that is
(this / value). |
T |
divideCeil(long value)
Returns a value that is
ceiling(this / value). |
T |
divideCeil(T value)
Returns a value that is
ceiling(this / value). |
default boolean |
fitsInt()
Returns true if the value can fit in an int.
|
default boolean |
fitsLong()
Returns true if the value can fit in a long.
|
default int |
intValue()
Provides this value as an int.
|
default boolean |
isZero()
Returns true is the value is 0.
|
T |
mod(long modulus)
Returns a value that is
(this mod modulus). |
T |
mod(UInt256 modulus)
Returns a value that is
(this mod modulus). |
T |
mod0(long modulus)
Returns a value that is
(this mod modulus), or 0 if modulus is 0. |
T |
mod0(UInt256 modulus)
Returns a value that is
(this mod modulus), or 0 if modulus is 0. |
T |
multiply(long value)
Returns a value that is
(this * value). |
T |
multiply(T value)
Returns a value that is
(this * value). |
T |
multiplyMod(long value,
long modulus)
Returns a value that is
((this * value) mod modulus). |
T |
multiplyMod(long value,
UInt256 modulus)
Returns a value that is
((this * value) mod modulus). |
T |
multiplyMod(T value,
UInt256 modulus)
Returns a value that is
((this * value) mod modulus). |
default int |
numberOfLeadingZeros()
Provides the number of zero bits preceding the highest-order one-bit.
|
default T |
plus(long value)
Returns a value that is
(this + value). |
default T |
plus(T value)
Returns a value that is
(this + value). |
T |
pow(long exponent)
Returns a value that is
(this<sup>exponent</sup> mod 2<sup>256</sup>)
This calculates an exponentiation over the modulus of 2^256. |
T |
pow(UInt256 exponent)
Returns a value that is
(this<sup>exponent</sup> mod 2<sup>256</sup>)
This calculates an exponentiation over the modulus of 2^256. |
T |
subtract(long value)
Returns a value that is
(this - value). |
T |
subtract(T value)
Returns a value that is
(this - value). |
default T |
subtractExact(long value)
Returns a value that is
(this - value). |
default T |
subtractExact(T value)
Returns a value that is
(this - value). |
default BigInteger |
toBigInteger()
Provides the value as a BigInteger.
|
Bytes32 |
toBytes()
Provides the value as bytes.
|
default String |
toHexString()
This value represented as an hexadecimal string.
|
default long |
toLong()
Provides the value as a long.
|
Bytes |
toMinimalBytes()
Provides the value as bytes without any leading zero bytes.
|
default String |
toShortHexString()
Returns this value represented as a minimal hexadecimal string (without any leading
zero)
|
UInt256 |
toUInt256()
Convert this value to a
UInt256. |
compareTodefault boolean isZero()
T add(T value)
(this + value).value - The amount to be added to this value.this + valuedefault T plus(T value)
(this + value).
This notation can be used in Kotlin with the + operator.
value - The amount to be added to this value.this + valuedefault T plus(long value)
(this + value).
This notation can be used in Kotlin with the + operator.
value - The amount to be added to this value.this + valuedefault T addExact(T value)
(this + value).value - the amount to be added to this valuethis + valueArithmeticException - if the result of the addition overflowsT add(long value)
(this + value).value - The amount to be added to this value.this + valuedefault T addExact(long value)
(this + value).value - the amount to be added to this valuethis + valueArithmeticException - if the result of the addition overflowsT addMod(T value, UInt256 modulus)
((this + value) mod modulus).value - The amount to be added to this value.modulus - The modulus.(this + value) mod modulusArithmeticException - modulus == 0.T addMod(long value, UInt256 modulus)
((this + value) mod modulus).value - The amount to be added to this value.modulus - The modulus.(this + value) mod modulusArithmeticException - modulus == 0.T addMod(long value, long modulus)
((this + value) mod modulus).value - The amount to be added to this value.modulus - The modulus.(this + value) mod modulusArithmeticException - modulus ≤ 0.T subtract(T value)
(this - value).value - The amount to be subtracted from this value.this - valuedefault T subtractExact(T value)
(this - value).value - the amount to be subtracted to this valuethis - valueArithmeticException - if the result of the addition overflowsT subtract(long value)
(this - value).value - The amount to be subtracted from this value.this - valuedefault T subtractExact(long value)
(this - value).value - the amount to be subtracted to this valuethis - valueArithmeticException - if the result of the addition overflowsT multiply(T value)
(this * value).value - The amount to multiply this value by.this * valueT multiply(long value)
(this * value).value - The amount to multiply this value by.this * valueArithmeticException - value < 0.T multiplyMod(T value, UInt256 modulus)
((this * value) mod modulus).value - The amount to multiply this value by.modulus - The modulus.(this * value) mod modulusArithmeticException - value < 0 or modulus == 0.T multiplyMod(long value, UInt256 modulus)
((this * value) mod modulus).value - The amount to multiply this value by.modulus - The modulus.(this * value) mod modulusArithmeticException - value < 0 or modulus == 0.T multiplyMod(long value, long modulus)
((this * value) mod modulus).value - The amount to multiply this value by.modulus - The modulus.(this * value) mod modulusArithmeticException - value < 0 or modulus ≤ 0.T divide(T value)
(this / value).value - The amount to divide this value by.this / valueArithmeticException - value == 0.T divide(long value)
(this / value).value - The amount to divide this value by.this / valueArithmeticException - value ≤ 0.T divideCeil(T value)
ceiling(this / value).value - The amount to divide this value by.this / value + ( this % value == 0 ? 0 : 1)ArithmeticException - value == 0.T divideCeil(long value)
ceiling(this / value).value - The amount to divide this value by.this / value + ( this % value == 0 ? 0 : 1)ArithmeticException - value == 0.T pow(UInt256 exponent)
(this<sup>exponent</sup> mod 2<sup>256</sup>)
This calculates an exponentiation over the modulus of 2^256.
Note that exponent is an UInt256 rather than of the type T.
exponent - The exponent to which this value is to be raised.this<sup>exponent</sup> mod 2<sup>256</sup>T pow(long exponent)
(this<sup>exponent</sup> mod 2<sup>256</sup>)
This calculates an exponentiation over the modulus of 2^256.
exponent - The exponent to which this value is to be raised.this<sup>exponent</sup> mod 2<sup>256</sup>T mod(UInt256 modulus)
(this mod modulus).modulus - The modulus.this mod modulus.ArithmeticException - modulus == 0.T mod(long modulus)
(this mod modulus).modulus - The modulus.this mod modulus.ArithmeticException - modulus ≤ 0.T mod0(UInt256 modulus)
(this mod modulus), or 0 if modulus is 0.modulus - The modulus.this mod modulus.T mod0(long modulus)
(this mod modulus), or 0 if modulus is 0.modulus - The modulus.this mod modulus.default boolean fitsInt()
int (i.e. is less or equal to
Integer.MAX_VALUE).default int intValue()
int assuming it is small enough to fit an
int.ArithmeticException - If the value does not fit an int, that is if
!fitsInt().default boolean fitsLong()
long (i.e. is less or equal to
Long.MAX_VALUE).default long toLong()
long assuming it is small enough to fit a
long.ArithmeticException - If the value does not fit a long, that is if
!fitsLong().default BigInteger toBigInteger()
BigInteger.default String toHexString()
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().
default String toShortHexString()
Bytes32 toBytes()
Bytes toMinimalBytes()
default int numberOfLeadingZeros()
default int bitLength()
Copyright © 2021. All rights reserved.