Skip to main content
@tevm/voltaire
@tevm/voltaire / primitives/Uint

primitives/Uint

Interfaces

UintConstructor()

Defined in: src/primitives/Uint/UintConstructor.ts:69
UintConstructor(value): Type
Defined in: src/primitives/Uint/UintConstructor.ts:70

Parameters

value
string | number | bigint

Returns

Type

Properties

bitLength()
bitLength: (uint) => number
Defined in: src/primitives/Uint/UintConstructor.ts:112 Get number of bits required to represent value
Parameters
uint
Type Value to check
Returns
number Number of bits (0-256)
Example
bitwiseAnd()
bitwiseAnd: (uint, b) => Type
Defined in: src/primitives/Uint/UintConstructor.ts:97 Bitwise AND
Parameters
uint
Type First operand
b
Type Second operand
Returns
Type uint & b
Example
bitwiseNot()
bitwiseNot: (uint) => Type
Defined in: src/primitives/Uint/UintConstructor.ts:100 Bitwise NOT
Parameters
uint
Type Operand
Returns
Type ~uint & MAX
Example
bitwiseOr()
bitwiseOr: (uint, b) => Type
Defined in: src/primitives/Uint/UintConstructor.ts:98 Bitwise OR
Parameters
uint
Type First operand
b
Type Second operand
Returns
Type uint | b
Example
bitwiseXor()
bitwiseXor: (uint, b) => Type
Defined in: src/primitives/Uint/UintConstructor.ts:99 Bitwise XOR
Parameters
uint
Type First operand
b
Type Second operand
Returns
Type uint ^ b
Example
dividedBy()
dividedBy: (uint, b) => Type
Defined in: src/primitives/Uint/UintConstructor.ts:94 Divide Uint256 value
Parameters
uint
Type Dividend
b
Type Divisor
Returns
Type Quotient (uint / b), floor division
Throws
Error if divisor is zero
Example
equals()
equals: (uint, b) => boolean
Defined in: src/primitives/Uint/UintConstructor.ts:103 Check equality
Parameters
uint
Type First value
b
Type Second value
Returns
boolean true if uint === b
Example
greaterThan()
greaterThan: (uint, b) => boolean
Defined in: src/primitives/Uint/UintConstructor.ts:107 Check greater than
Parameters
uint
Type First value
b
Type Second value
Returns
boolean true if uint > b
Example
greaterThanOrEqual()
greaterThanOrEqual: (uint, b) => boolean
Defined in: src/primitives/Uint/UintConstructor.ts:108 Check greater than or equal
Parameters
uint
Type First value
b
Type Second value
Returns
boolean true if uint >= b
Example
isValid()
isValid: (value) => value is Type
Defined in: src/primitives/Uint/UintConstructor.ts:84 Check if value is a valid Uint256
Parameters
value
unknown Value to check
Returns
value is Type true if value is valid Uint256
Example
isZero()
isZero: (uint) => boolean
Defined in: src/primitives/Uint/UintConstructor.ts:109 Check if value is zero
Parameters
uint
Type Value to check
Returns
boolean true if uint === 0
Example
leadingZeros()
leadingZeros: (uint) => number
Defined in: src/primitives/Uint/UintConstructor.ts:113 Get number of leading zero bits
Parameters
uint
Type Value to check
Returns
number Number of leading zeros (0-256)
Example
lessThan()
lessThan: (uint, b) => boolean
Defined in: src/primitives/Uint/UintConstructor.ts:105 Check less than
Parameters
uint
Type First value
b
Type Second value
Returns
boolean true if uint < b
Example
lessThanOrEqual()
lessThanOrEqual: (uint, b) => boolean
Defined in: src/primitives/Uint/UintConstructor.ts:106 Check less than or equal
Parameters
uint
Type First value
b
Type Second value
Returns
boolean true if uint is less than or equal to b
Example
MAX
MAX: Type
Defined in: src/primitives/Uint/UintConstructor.ts:72
maximum()
maximum: (uint, b) => Type
Defined in: src/primitives/Uint/UintConstructor.ts:111 Get maximum of two values
Parameters
uint
Type First value
b
Type Second value
Returns
Type max(uint, b)
Example
MIN
MIN: Type
Defined in: src/primitives/Uint/UintConstructor.ts:73
minimum()
minimum: (uint, b) => Type
Defined in: src/primitives/Uint/UintConstructor.ts:110 Get minimum of two values
Parameters
uint
Type First value
b
Type Second value
Returns
Type min(uint, b)
Example
minus()
minus: (uint, b) => Type
Defined in: src/primitives/Uint/UintConstructor.ts:92 Subtract Uint256 value with wrapping
Parameters
uint
Type First operand
b
Type Second operand
Returns
Type Difference (uint - b) mod 2^256
Example
modulo()
modulo: (uint, b) => Type
Defined in: src/primitives/Uint/UintConstructor.ts:95 Modulo operation
Parameters
uint
Type Dividend
b
Type Divisor
Returns
Type Remainder (uint % b)
Throws
Error if divisor is zero
Example
notEquals()
notEquals: (uint, b) => boolean
Defined in: src/primitives/Uint/UintConstructor.ts:104 Check inequality
Parameters
uint
Type First value
b
Type Second value
Returns
boolean true if uint !== b
Example
ONE
ONE: Type
Defined in: src/primitives/Uint/UintConstructor.ts:75
plus()
plus: (uint, b) => Type
Defined in: src/primitives/Uint/UintConstructor.ts:91 Add Uint256 value with wrapping
Parameters
uint
Type First operand
b
Type Second operand
Returns
Type Sum (uint + b) mod 2^256
Example
popCount()
popCount: (uint) => number
Defined in: src/primitives/Uint/UintConstructor.ts:114 Count number of set bits (population count)
Parameters
uint
Type Value to check
Returns
number Number of 1 bits
Example
prototype
prototype: UintPrototype
Defined in: src/primitives/Uint/UintConstructor.ts:71
shiftLeft()
shiftLeft: (uint, bits) => Type
Defined in: src/primitives/Uint/UintConstructor.ts:101 Left shift
Parameters
uint
Type Value to shift
bits
Type Number of bits to shift
Returns
Type uint shifted left by bits (mod 2^256)
Example
shiftRight()
shiftRight: (uint, bits) => Type
Defined in: src/primitives/Uint/UintConstructor.ts:102 Right shift
Parameters
uint
Type Value to shift
bits
Type Number of bits to shift
Returns
Type uint shifted right by bits
Example
SIZE
SIZE: number
Defined in: src/primitives/Uint/UintConstructor.ts:76
times()
times: (uint, b) => Type
Defined in: src/primitives/Uint/UintConstructor.ts:93 Multiply Uint256 value with wrapping
Parameters
uint
Type First operand
b
Type Second operand
Returns
Type Product (uint * b) mod 2^256
Example
toAbiEncoded()
toAbiEncoded: (uint) => Uint8Array
Defined in: src/primitives/Uint/UintConstructor.ts:89 Convert Uint256 to ABI-encoded bytes (32 bytes, big-endian) This is identical to toBytes() - all Uint256 values in ABI encoding are represented as 32-byte big-endian values.
Parameters
uint
Type Uint256 value to encode
Returns
Uint8Array 32-byte ABI-encoded Uint8Array
Example
toBigInt()
toBigInt: (uint) => bigint
Defined in: src/primitives/Uint/UintConstructor.ts:86 Convert Uint256 to bigint
Parameters
uint
Type Uint256 value to convert
Returns
bigint bigint value
Example
toBytes()
toBytes: (uint) => Uint8Array
Defined in: src/primitives/Uint/UintConstructor.ts:88 Convert Uint256 to bytes (big-endian, 32 bytes)
Parameters
uint
Type Uint256 value to convert
Returns
Uint8Array 32-byte Uint8Array
Example
toHex()
toHex: (uint, padded) => string
Defined in: src/primitives/Uint/UintConstructor.ts:85 Convert Uint256 to hex string
Parameters
uint
Type Uint256 value to convert
padded
boolean = true Whether to pad to 64 characters (32 bytes)
Returns
string Hex string with 0x prefix
Example
toNumber()
toNumber: (uint) => number
Defined in: src/primitives/Uint/UintConstructor.ts:87 Convert Uint256 to number
Parameters
uint
Type Uint256 value to convert
Returns
number number value
Throws
Error if value exceeds MAX_SAFE_INTEGER
Example
toPower()
toPower: (uint, exponent) => Type
Defined in: src/primitives/Uint/UintConstructor.ts:96 Exponentiation
Parameters
uint
Type Base value
exponent
Type Exponent value
Returns
Type uint^exponent mod 2^256
Example
toString()
toString: (uint, radix) => string
Defined in: src/primitives/Uint/UintConstructor.ts:90 Convert Uint256 to string representation
Parameters
uint
Type Uint256 value to convert
radix
number = 10 Base for string conversion (2, 10, 16, etc.)
Returns
string String representation
Example
tryFrom()
tryFrom: (value) => Type | undefined
Defined in: src/primitives/Uint/UintConstructor.ts:83 Try to create Uint256, returns undefined if invalid (standard form)
Parameters
value
bigint, number, or string string | number | bigint
Returns
Type | undefined Uint256 value or undefined
Example
ZERO
ZERO: Type
Defined in: src/primitives/Uint/UintConstructor.ts:74

Methods

from()
from(value): Type
Defined in: src/primitives/Uint/UintConstructor.ts:77
Parameters
value
string | number | bigint
Returns
Type
fromAbiEncoded()
fromAbiEncoded(value): Type
Defined in: src/primitives/Uint/UintConstructor.ts:82
Parameters
value
Uint8Array
Returns
Type
fromBigInt()
fromBigInt(value): Type
Defined in: src/primitives/Uint/UintConstructor.ts:79
Parameters
value
bigint
Returns
Type
fromBytes()
fromBytes(value): Type
Defined in: src/primitives/Uint/UintConstructor.ts:81
Parameters
value
Uint8Array
Returns
Type
fromHex()
fromHex(value): Type
Defined in: src/primitives/Uint/UintConstructor.ts:78
Parameters
value
string
Returns
Type
fromNumber()
fromNumber(value): Type
Defined in: src/primitives/Uint/UintConstructor.ts:80
Parameters
value
number | bigint
Returns
Type

Type Aliases

BrandedUint

BrandedUint = Type
Defined in: src/primitives/Uint/Uint256Type.ts:19

Deprecated

Use Uint256Type instead

BrandedUint256

BrandedUint256 = Type
Defined in: src/primitives/Uint/Uint256Type.ts:14

Deprecated

Use Uint256Type instead

Type

Type = bigint & object
Defined in: src/primitives/Uint/Uint256Type.ts:9 Uint256 type

Type Declaration

[brand]
readonly [brand]: "Uint256"

See

https://voltaire.tevm.sh/primitives/uint256 for Uint256 documentation

Since

0.0.0

Variables

MAX

const MAX: Type
Defined in: src/primitives/Uint/constants.ts:17 Maximum Uint256 value: 2^256 - 1

See

https://voltaire.tevm.sh/primitives/uint for Uint documentation

Since

0.0.0

MIN

const MIN: Type
Defined in: src/primitives/Uint/constants.ts:25 Minimum Uint256 value: 0

See

https://voltaire.tevm.sh/primitives/uint for Uint documentation

Since

0.0.0

ONE

const ONE: Type
Defined in: src/primitives/Uint/constants.ts:41 One value

See

https://voltaire.tevm.sh/primitives/uint for Uint documentation

Since

0.0.0

SIZE

const SIZE: 32 = 32
Defined in: src/primitives/Uint/constants.ts:9 Size in bytes (32 bytes for Uint256)

See

https://voltaire.tevm.sh/primitives/uint for Uint documentation

Since

0.0.0

Uint256Type

const Uint256Type: object
Defined in: src/primitives/Uint/index.ts:105

Type Declaration

bitLength()
bitLength: (uint) => number
Parameters
uint
Type
Returns
number
bitwiseAnd()
bitwiseAnd: (uint, b) => Type
Parameters
uint
Type
b
Type
Returns
Type
bitwiseNot()
bitwiseNot: (uint) => Type
Parameters
uint
Type
Returns
Type
bitwiseOr()
bitwiseOr: (uint, b) => Type
Parameters
uint
Type
b
Type
Returns
Type
bitwiseXor()
bitwiseXor: (uint, b) => Type
Parameters
uint
Type
b
Type
Returns
Type
clone()
clone: (uint) => Type
Parameters
uint
Type
Returns
Type
dividedBy()
dividedBy: (uint, b) => Type
Parameters
uint
Type
b
Type
Returns
Type
equals()
equals: (uint, b) => boolean
Parameters
uint
Type
b
Type
Returns
boolean
from()
from: (value) => Type
Parameters
value
bigint | number | string
Returns
Type
fromAbiEncoded()
fromAbiEncoded: (data) => Type
Parameters
data
Uint8Array
Returns
Type
fromBigInt()
fromBigInt: (value) => Type
Parameters
value
bigint
Returns
Type
fromBytes()
fromBytes: (bytes) => Type
Parameters
bytes
Uint8Array
Returns
Type
fromHex()
fromHex: (hex) => Type
Parameters
hex
string
Returns
Type
fromNumber()
fromNumber: (value) => Type
Parameters
value
number
Returns
Type
gcd()
gcd: (a, b) => Type
Parameters
a
Type
b
Type
Returns
Type
greaterThan()
greaterThan: (uint, b) => boolean
Parameters
uint
Type
b
Type
Returns
boolean
greaterThanOrEqual()
greaterThanOrEqual: (uint, b) => boolean
Parameters
uint
Type
b
Type
Returns
boolean
isPowerOf2()
isPowerOf2: (uint) => boolean
Parameters
uint
Type
Returns
boolean
isValid()
isValid: (value) => value is Type
Parameters
value
unknown
Returns
value is Type
isZero()
isZero: (uint) => boolean
Parameters
uint
Type
Returns
boolean
lcm()
lcm: (a, b) => Type
Parameters
a
Type
b
Type
Returns
Type
leadingZeros()
leadingZeros: (uint) => number
Parameters
uint
Type
Returns
number
lessThan()
lessThan: (uint, b) => boolean
Parameters
uint
Type
b
Type
Returns
boolean
lessThanOrEqual()
lessThanOrEqual: (uint, b) => boolean
Parameters
uint
Type
b
Type
Returns
boolean
max()
max: (…values) => Type
Parameters
values
Type[]
Returns
Type
MAX
MAX: Type
maximum()
maximum: (uint, b) => Type
Parameters
uint
Type
b
Type
Returns
Type
min()
min: (…values) => Type
Parameters
values
Type[]
Returns
Type
MIN
MIN: Type
minimum()
minimum: (uint, b) => Type
Parameters
uint
Type
b
Type
Returns
Type
minus()
minus: (uint, b) => Type
Parameters
uint
Type
b
Type
Returns
Type
modulo()
modulo: (uint, b) => Type
Parameters
uint
Type
b
Type
Returns
Type
notEquals()
notEquals: (uint, b) => boolean
Parameters
uint
Type
b
Type
Returns
boolean
ONE
ONE: Type
plus()
plus: (uint, b) => Type
Parameters
uint
Type
b
Type
Returns
Type
popCount()
popCount: (uint) => number
Parameters
uint
Type
Returns
number
product()
product: (…values) => Type
Parameters
values
Type[]
Returns
Type
shiftLeft()
shiftLeft: (uint, bits) => Type
Parameters
uint
Type
bits
Type
Returns
Type
shiftRight()
shiftRight: (uint, bits) => Type
Parameters
uint
Type
bits
Type
Returns
Type
SIZE
SIZE: 32
sum()
sum: (…values) => Type
Parameters
values
Type[]
Returns
Type
times()
times: (uint, b) => Type
Parameters
uint
Type
b
Type
Returns
Type
toAbiEncoded()
toAbiEncoded: (uint) => Uint8Array
Parameters
uint
Type
Returns
Uint8Array
toBigInt()
toBigInt: (uint) => bigint
Parameters
uint
Type
Returns
bigint
toBytes()
toBytes: (uint, size?) => Uint8Array
Parameters
uint
Type
size?
number
Returns
Uint8Array
toHex()
toHex: (uint, padded?) => string
Parameters
uint
Type
padded?
boolean
Returns
string
toNumber()
toNumber: (uint) => number
Parameters
uint
Type
Returns
number
toPower()
toPower: (uint, exponent) => Type
Parameters
uint
Type
exponent
Type
Returns
Type
toString()
toString: (uint, radix?) => string
Parameters
uint
Type
radix?
number
Returns
string
tryFrom()
tryFrom: (value) => Type | undefined
Parameters
value
bigint | number | string
Returns
Type | undefined
ZERO
ZERO: Type

ZERO

const ZERO: Type
Defined in: src/primitives/Uint/constants.ts:33 Zero value

See

https://voltaire.tevm.sh/primitives/uint for Uint documentation

Since

0.0.0

Functions

bitLength()

bitLength(uint): number
Defined in: src/primitives/Uint/bitLength.ts:16 Get number of bits required to represent value

Parameters

uint
Type Value to check

Returns

number Number of bits (0-256)

Example


bitwiseAnd()

bitwiseAnd(uint, b): Type
Defined in: src/primitives/Uint/bitwiseAnd.ts:18 Bitwise AND

Parameters

uint
Type First operand
b
Type Second operand

Returns

Type uint & b

Example


bitwiseNot()

bitwiseNot(uint): Type
Defined in: src/primitives/Uint/bitwiseNot.ts:17 Bitwise NOT

Parameters

uint
Type Operand

Returns

Type ~uint & MAX

Example


bitwiseOr()

bitwiseOr(uint, b): Type
Defined in: src/primitives/Uint/bitwiseOr.ts:18 Bitwise OR

Parameters

uint
Type First operand
b
Type Second operand

Returns

Type uint | b

Example


bitwiseXor()

bitwiseXor(uint, b): Type
Defined in: src/primitives/Uint/bitwiseXor.ts:18 Bitwise XOR

Parameters

uint
Type First operand
b
Type Second operand

Returns

Type uint ^ b

Example


clone()

clone(uint): Type
Defined in: src/primitives/Uint/clone.js:17 Create a copy of a Uint256 value

Parameters

uint
Type Uint256 value to clone

Returns

Type Copy of the value

See

https://voltaire.tevm.sh/primitives/uint for Uint documentation

Since

0.0.0

Throws

Example


dividedBy()

dividedBy(uint, b): Type
Defined in: src/primitives/Uint/dividedBy.ts:19 Divide Uint256 value

Parameters

uint
Type Dividend
b
Type Divisor

Returns

Type Quotient (uint / b), floor division

Throws

Error if divisor is zero

Example


equals()

equals(uint, b): boolean
Defined in: src/primitives/Uint/equals.ts:18 Check equality

Parameters

uint
Type First value
b
Type Second value

Returns

boolean true if uint === b

Example


from()

from(value): Type
Defined in: src/primitives/Uint/from.ts:18 Create Uint256 from bigint or string (standard form)

Parameters

value
bigint or decimal/hex string string | number | bigint

Returns

Type Uint256 value

Throws

Error if value is out of range or invalid

Example


fromAbiEncoded()

fromAbiEncoded(bytes): Type
Defined in: src/primitives/Uint/fromAbiEncoded.ts:18 Decode Uint256 from ABI-encoded bytes (32 bytes, big-endian)

Parameters

bytes
Uint8Array 32-byte ABI-encoded data

Returns

Type Decoded Uint256 value

Throws

Error if bytes length is not 32

Example


fromBigInt()

fromBigInt(value): Type
Defined in: src/primitives/Uint/fromBigInt.ts:16 Create Uint256 from bigint

Parameters

value
bigint bigint to convert

Returns

Type Uint256 value

Throws

Error if value out of range

Example


fromBytes()

fromBytes(bytes): Type
Defined in: src/primitives/Uint/fromBytes.ts:16 Create Uint256 from bytes (big-endian)

Parameters

bytes
Uint8Array bytes to convert

Returns

Type Uint256 value

Throws

Error if bytes length exceeds 32

Example


fromHex()

fromHex(hex): Type
Defined in: src/primitives/Uint/fromHex.ts:19 Create Uint256 from hex string

Parameters

hex
string Hex string to convert

Returns

Type Uint256 value

Throws

If value is negative

Throws

If value exceeds maximum

Example


fromNumber()

fromNumber(value): Type
Defined in: src/primitives/Uint/fromNumber.ts:16 Create Uint256 from number

Parameters

value
number number to convert

Returns

Type Uint256 value

Throws

Error if value is not an integer or out of range

Example


gcd()

gcd(a, b): Type
Defined in: src/primitives/Uint/gcd.js:18 Calculate greatest common divisor using Euclidean algorithm

Parameters

a
Type First value
b
Type Second value

Returns

Type GCD of a and b

See

https://voltaire.tevm.sh/primitives/uint for Uint documentation

Since

0.0.0

Throws

Example


greaterThan()

greaterThan(uint, b): boolean
Defined in: src/primitives/Uint/greaterThan.ts:18 Check greater than

Parameters

uint
Type First value
b
Type Second value

Returns

boolean true if uint > b

Example


greaterThanOrEqual()

greaterThanOrEqual(uint, b): boolean
Defined in: src/primitives/Uint/greaterThanOrEqual.ts:18 Check greater than or equal

Parameters

uint
Type First value
b
Type Second value

Returns

boolean true if uint >= b

Example


isPowerOf2()

isPowerOf2(value): boolean
Defined in: src/primitives/Uint/isPowerOf2.js:18 Check if value is a power of 2

Parameters

value
Type Value to check

Returns

boolean True if value is power of 2

See

https://voltaire.tevm.sh/primitives/uint for Uint documentation

Since

0.0.0

Throws

Example


isValid()

isValid(value): value is Type
Defined in: src/primitives/Uint/isValid.ts:16 Check if value is a valid Uint256

Parameters

value
unknown Value to check

Returns

value is Type true if value is valid Uint256

Example


isZero()

isZero(uint): boolean
Defined in: src/primitives/Uint/isZero.ts:16 Check if value is zero

Parameters

uint
Type Value to check

Returns

boolean true if uint === 0

Example


lcm()

lcm(a, b): Type
Defined in: src/primitives/Uint/lcm.js:19 Calculate least common multiple

Parameters

a
Type First value
b
Type Second value

Returns

Type LCM of a and b

See

https://voltaire.tevm.sh/primitives/uint for Uint documentation

Since

0.0.0

Throws

Example


leadingZeros()

leadingZeros(uint): number
Defined in: src/primitives/Uint/leadingZeros.ts:17 Get number of leading zero bits

Parameters

uint
Type Value to check

Returns

number Number of leading zeros (0-256)

Example


lessThan()

lessThan(uint, b): boolean
Defined in: src/primitives/Uint/lessThan.ts:18 Check less than

Parameters

uint
Type First value
b
Type Second value

Returns

boolean true if uint < b

Example


lessThanOrEqual()

lessThanOrEqual(uint, b): boolean
Defined in: src/primitives/Uint/lessThanOrEqual.ts:18 Check less than or equal

Parameters

uint
Type First value
b
Type Second value

Returns

boolean true if uint is less than or equal to b

Example


max()

max(…values): Type
Defined in: src/primitives/Uint/max.js:17 Find maximum of multiple Uint256 values

Parameters

values
Type[] Values to compare

Returns

Type Maximum value

See

https://voltaire.tevm.sh/primitives/uint for Uint documentation

Since

0.0.0

Throws

If no values provided

Example


maximum()

maximum(uint, b): Type
Defined in: src/primitives/Uint/maximum.ts:18 Get maximum of two values

Parameters

uint
Type First value
b
Type Second value

Returns

Type max(uint, b)

Example


min()

min(…values): Type
Defined in: src/primitives/Uint/min.js:15 Find minimum of multiple Uint256 values

Parameters

values
Type[] Values to compare

Returns

Type Minimum value

See

https://voltaire.tevm.sh/primitives/uint for Uint documentation

Since

0.0.0

Throws

If no values provided

Example


minimum()

minimum(uint, b): Type
Defined in: src/primitives/Uint/minimum.ts:18 Get minimum of two values

Parameters

uint
Type First value
b
Type Second value

Returns

Type min(uint, b)

Example


minus()

minus(uint, b): Type
Defined in: src/primitives/Uint/minus.ts:19 Subtract Uint256 value with wrapping

Parameters

uint
Type First operand
b
Type Second operand

Returns

Type Difference (uint - b) mod 2^256

Example


modulo()

modulo(uint, b): Type
Defined in: src/primitives/Uint/modulo.ts:19 Modulo operation

Parameters

uint
Type Dividend
b
Type Divisor

Returns

Type Remainder (uint % b)

Throws

Error if divisor is zero

Example


notEquals()

notEquals(uint, b): boolean
Defined in: src/primitives/Uint/notEquals.ts:18 Check inequality

Parameters

uint
Type First value
b
Type Second value

Returns

boolean true if uint !== b

Example


plus()

plus(uint, b): Type
Defined in: src/primitives/Uint/plus.ts:19 Add Uint256 value with wrapping

Parameters

uint
Type First operand
b
Type Second operand

Returns

Type Sum (uint + b) mod 2^256

Example


popCount()

popCount(uint): number
Defined in: src/primitives/Uint/popCount.ts:16 Count number of set bits (population count)

Parameters

uint
Type Value to check

Returns

number Number of 1 bits

Example


product()

product(…values): Type
Defined in: src/primitives/Uint/product.js:17 Multiply multiple Uint256 values with wrapping

Parameters

values
Type[] Values to multiply

Returns

Type Product of all values mod 2^256

See

https://voltaire.tevm.sh/primitives/uint for Uint documentation

Since

0.0.0

Throws

Example


shiftLeft()

shiftLeft(uint, bits): Type
Defined in: src/primitives/Uint/shiftLeft.ts:19 Left shift

Parameters

uint
Type Value to shift
bits
Type Number of bits to shift

Returns

Type uint shifted left by bits (mod 2^256)

Example


shiftRight()

shiftRight(uint, bits): Type
Defined in: src/primitives/Uint/shiftRight.ts:18 Right shift

Parameters

uint
Type Value to shift
bits
Type Number of bits to shift

Returns

Type uint shifted right by bits

Example


sum()

sum(…values): Type
Defined in: src/primitives/Uint/sum.js:17 Sum multiple Uint256 values with wrapping

Parameters

values
Type[] Values to sum

Returns

Type Sum of all values mod 2^256

See

https://voltaire.tevm.sh/primitives/uint for Uint documentation

Since

0.0.0

Throws

Example


times()

times(uint, b): Type
Defined in: src/primitives/Uint/times.ts:19 Multiply Uint256 value with wrapping

Parameters

uint
Type First operand
b
Type Second operand

Returns

Type Product (uint * b) mod 2^256

Example


toAbiEncoded()

toAbiEncoded(uint): Uint8Array
Defined in: src/primitives/Uint/toAbiEncoded.ts:20 Convert Uint256 to ABI-encoded bytes (32 bytes, big-endian) This is identical to toBytes() - all Uint256 values in ABI encoding are represented as 32-byte big-endian values.

Parameters

uint
Type Uint256 value to encode

Returns

Uint8Array 32-byte ABI-encoded Uint8Array

Example


toBigInt()

toBigInt(uint): bigint
Defined in: src/primitives/Uint/toBigInt.ts:16 Convert Uint256 to bigint

Parameters

uint
Type Uint256 value to convert

Returns

bigint bigint value

Example


toBytes()

toBytes(uint): Uint8Array
Defined in: src/primitives/Uint/toBytes.ts:16 Convert Uint256 to bytes (big-endian, 32 bytes)

Parameters

uint
Type Uint256 value to convert

Returns

Uint8Array 32-byte Uint8Array

Example


toHex()

toHex(uint, padded): string
Defined in: src/primitives/Uint/toHex.ts:18 Convert Uint256 to hex string

Parameters

uint
Type Uint256 value to convert
padded
boolean = true Whether to pad to 64 characters (32 bytes)

Returns

string Hex string with 0x prefix

Example


toNumber()

toNumber(uint): number
Defined in: src/primitives/Uint/toNumber.ts:17 Convert Uint256 to number

Parameters

uint
Type Uint256 value to convert

Returns

number number value

Throws

Error if value exceeds MAX_SAFE_INTEGER

Example


toPower()

toPower(uint, exponent): Type
Defined in: src/primitives/Uint/toPower.ts:19 Exponentiation

Parameters

uint
Type Base value
exponent
Type Exponent value

Returns

Type uint^exponent mod 2^256

Example


toString()

toString(uint, radix): string
Defined in: src/primitives/Uint/toString.ts:19 Convert Uint256 to string representation

Parameters

uint
Type Uint256 value to convert
radix
number = 10 Base for string conversion (2, 10, 16, etc.)

Returns

string String representation

Example


tryFrom()

tryFrom(value): Type | undefined
Defined in: src/primitives/Uint/tryFrom.ts:17 Try to create Uint256, returns undefined if invalid (standard form)

Parameters

value
bigint, number, or string string | number | bigint

Returns

Type | undefined Uint256 value or undefined

Example

References

Uint256

Renames and re-exports Uint256Type