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

primitives/Uint16

Variables

MAX

const MAX: Uint16Type
Defined in: src/primitives/Uint16/constants.js:12

MIN

const MIN: Uint16Type
Defined in: src/primitives/Uint16/constants.js:9

ONE

const ONE: Uint16Type
Defined in: src/primitives/Uint16/constants.js:18

SIZE

const SIZE: number = 16
Defined in: src/primitives/Uint16/constants.js:21

Uint16Type

const Uint16Type: object
Defined in: src/primitives/Uint16/index.ts:72

Type Declaration

bitLength()
bitLength: (uint) => number
Get bit length of Uint16 value (position of highest set bit)
Parameters
uint
Uint16Type Input value
Returns
number Number of bits needed to represent value (0-16)
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation
Since
0.0.0
Throws
Example
bitwiseAnd()
bitwiseAnd: (a, b) => Uint16Type
Bitwise AND of two Uint16 values
Parameters
a
Uint16Type First operand
b
Uint16Type Second operand
Returns
Uint16Type Bitwise AND result
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation
Since
0.0.0
Throws
Example
bitwiseNot()
bitwiseNot: (uint) => Uint16Type
Bitwise NOT of Uint16 value
Parameters
uint
Uint16Type Input value
Returns
Uint16Type Bitwise NOT result
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation
Since
0.0.0
Throws
Example
bitwiseOr()
bitwiseOr: (a, b) => Uint16Type
Bitwise OR of two Uint16 values
Parameters
a
Uint16Type First operand
b
Uint16Type Second operand
Returns
Uint16Type Bitwise OR result
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation
Since
0.0.0
Throws
Example
bitwiseXor()
bitwiseXor: (a, b) => Uint16Type
Bitwise XOR of two Uint16 values
Parameters
a
Uint16Type First operand
b
Uint16Type Second operand
Returns
Uint16Type Bitwise XOR result
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation
Since
0.0.0
Throws
Example
dividedBy()
dividedBy: (a, b) => Uint16Type
Divide two Uint16 values (integer division)
Parameters
a
Uint16Type Dividend
b
Uint16Type Divisor
Returns
Uint16Type Quotient (floor(a / b))
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation
Since
0.0.0
Throws
If divisor is zero
Example
equals()
equals: (a, b) => boolean
Check if two Uint16 values are equal
Parameters
a
Uint16Type First operand
b
Uint16Type Second operand
Returns
boolean true if a === b
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation
Since
0.0.0
Throws
Example
from()
from: (value) => Uint16Type
Create Uint16 from number or string
Parameters
value
number or decimal/hex string string | number
Returns
Uint16Type Uint16 value
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation
Since
0.0.0
Throws
If value is out of range or invalid
Example
fromBigint()
fromBigint: (value) => Uint16Type
Create Uint16 from bigint
Parameters
value
bigint bigint value
Returns
Uint16Type Uint16 value
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation
Since
0.0.0
Throws
If value is out of range
Example
fromBytes()
fromBytes: (bytes) => Uint16Type
Create Uint16 from Uint8Array (2 bytes, big-endian)
Parameters
bytes
Uint8Array<ArrayBufferLike> Uint8Array (must be exactly 2 bytes)
Returns
Uint16Type Uint16 value
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation
Since
0.0.0
Throws
If bytes length is not 2
Example
fromHex()
fromHex: (hex) => Uint16Type
Create Uint16 from hex string
Parameters
hex
string hex string (with or without 0x prefix)
Returns
Uint16Type Uint16 value
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation
Since
0.0.0
Throws
If hex is invalid or out of range
Example
fromNumber()
fromNumber: (value) => Uint16Type
Create Uint16 from number
Parameters
value
number number value
Returns
Uint16Type Uint16 value
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation
Since
0.0.0
Throws
If value is out of range or not an integer
Example
greaterThan()
greaterThan: (a, b) => boolean
Check if first Uint16 is greater than second
Parameters
a
Uint16Type First operand
b
Uint16Type Second operand
Returns
boolean true if a > b
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation
Since
0.0.0
Throws
Example
isValid()
isValid: (value) => value is Uint16Type
Check if value is a valid Uint16
Parameters
value
unknown Value to check
Returns
value is Uint16Type true if valid Uint16
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation
Since
0.0.0
Throws
Example
isZero()
isZero: (uint) => boolean
Check if Uint16 value is zero
Parameters
uint
Uint16Type Uint16 value
Returns
boolean true if uint === 0
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation
Since
0.0.0
Throws
Example
leadingZeros()
leadingZeros: (uint) => number
Count leading zero bits in Uint16 value
Parameters
uint
Uint16Type Input value
Returns
number Number of leading zero bits (0-16)
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation
Since
0.0.0
Throws
Example
lessThan()
lessThan: (a, b) => boolean
Check if first Uint16 is less than second
Parameters
a
Uint16Type First operand
b
Uint16Type Second operand
Returns
boolean true if a < b
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation
Since
0.0.0
Throws
Example
MAX
MAX: Uint16Type
maximum()
maximum: (a, b) => Uint16Type
Return maximum of two Uint16 values
Parameters
a
Uint16Type First operand
b
Uint16Type Second operand
Returns
Uint16Type Maximum value
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation
Since
0.0.0
Throws
Example
MIN
MIN: Uint16Type
minimum()
minimum: (a, b) => Uint16Type
Return minimum of two Uint16 values
Parameters
a
Uint16Type First operand
b
Uint16Type Second operand
Returns
Uint16Type Minimum value
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation
Since
0.0.0
Throws
Example
minus()
minus: (a, b) => Uint16Type
Subtract two Uint16 values with underflow checking
Parameters
a
Uint16Type First operand
b
Uint16Type Second operand
Returns
Uint16Type Difference (a - b)
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation
Since
0.0.0
Throws
If result is negative
Example
modulo()
modulo: (a, b) => Uint16Type
Compute modulo of two Uint16 values
Parameters
a
Uint16Type Dividend
b
Uint16Type Divisor
Returns
Uint16Type Remainder (a % b)
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation
Since
0.0.0
Throws
If divisor is zero
Example
ONE
ONE: Uint16Type
plus()
plus: (a, b) => Uint16Type
Add two Uint16 values with overflow checking
Parameters
a
Uint16Type First operand
b
Uint16Type Second operand
Returns
Uint16Type Sum (a + b)
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation
Since
0.0.0
Throws
If result exceeds maximum value
Example
popCount()
popCount: (uint) => number
Count number of set bits (population count) in Uint16 value
Parameters
uint
Uint16Type Input value
Returns
number Number of set bits (0-16)
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation
Since
0.0.0
Throws
Example
shiftLeft()
shiftLeft: (uint, shift) => Uint16Type
Left shift Uint16 value
Parameters
uint
Uint16Type Value to shift
shift
number Number of bits to shift (0-15)
Returns
Uint16Type Left-shifted value (masked to 16 bits)
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation
Since
0.0.0
Throws
Example
shiftRight()
shiftRight: (uint, shift) => Uint16Type
Right shift Uint16 value (logical shift)
Parameters
uint
Uint16Type Value to shift
shift
number Number of bits to shift (0-15)
Returns
Uint16Type Right-shifted value
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation
Since
0.0.0
Throws
Example
SIZE
SIZE: number
times()
times: (a, b) => Uint16Type
Multiply two Uint16 values with overflow checking
Parameters
a
Uint16Type First operand
b
Uint16Type Second operand
Returns
Uint16Type Product (a * b)
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation
Since
0.0.0
Throws
If result exceeds maximum value
Example
toBigint()
toBigint: (uint) => bigint
Convert Uint16 to bigint
Parameters
uint
Uint16Type Uint16 value
Returns
bigint bigint value
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation
Since
0.0.0
Throws
Example
toBytes()
toBytes: (uint) => Uint8Array<ArrayBufferLike>
Convert Uint16 to Uint8Array (2 bytes, big-endian)
Parameters
uint
Uint16Type Uint16 value
Returns
Uint8Array<ArrayBufferLike> Uint8Array of length 2
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation
Since
0.0.0
Throws
Example
toHex()
toHex: (uint, padded?) => string
Convert Uint16 to hex string
Parameters
uint
Uint16Type Uint16 value
padded?
boolean = true Whether to pad to 4 characters (2 bytes)
Returns
string Hex string with 0x prefix
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation
Since
0.0.0
Throws
Example
toNumber()
toNumber: (uint) => number
Convert Uint16 to number
Parameters
uint
Uint16Type Uint16 value
Returns
number number value
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation
Since
0.0.0
Throws
Example
toString()
toString: (uint) => string
Convert Uint16 to decimal string
Parameters
uint
Uint16Type Uint16 value
Returns
string Decimal string representation
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation
Since
0.0.0
Throws
Example
ZERO
ZERO: Uint16Type

ZERO

const ZERO: Uint16Type
Defined in: src/primitives/Uint16/constants.js:15

Functions

bitLength()

bitLength(uint): number
Defined in: src/primitives/Uint16/bitLength.js:18 Get bit length of Uint16 value (position of highest set bit)

Parameters

uint
Uint16Type Input value

Returns

number Number of bits needed to represent value (0-16)

See

https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation

Since

0.0.0

Throws

Example


bitwiseAnd()

bitwiseAnd(a, b): Uint16Type
Defined in: src/primitives/Uint16/bitwiseAnd.js:18 Bitwise AND of two Uint16 values

Parameters

a
Uint16Type First operand
b
Uint16Type Second operand

Returns

Uint16Type Bitwise AND result

See

https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation

Since

0.0.0

Throws

Example


bitwiseNot()

bitwiseNot(uint): Uint16Type
Defined in: src/primitives/Uint16/bitwiseNot.js:18 Bitwise NOT of Uint16 value

Parameters

uint
Uint16Type Input value

Returns

Uint16Type Bitwise NOT result

See

https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation

Since

0.0.0

Throws

Example


bitwiseOr()

bitwiseOr(a, b): Uint16Type
Defined in: src/primitives/Uint16/bitwiseOr.js:18 Bitwise OR of two Uint16 values

Parameters

a
Uint16Type First operand
b
Uint16Type Second operand

Returns

Uint16Type Bitwise OR result

See

https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation

Since

0.0.0

Throws

Example


bitwiseXor()

bitwiseXor(a, b): Uint16Type
Defined in: src/primitives/Uint16/bitwiseXor.js:18 Bitwise XOR of two Uint16 values

Parameters

a
Uint16Type First operand
b
Uint16Type Second operand

Returns

Uint16Type Bitwise XOR result

See

https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation

Since

0.0.0

Throws

Example


dividedBy()

dividedBy(a, b): Uint16Type
Defined in: src/primitives/Uint16/dividedBy.js:18 Divide two Uint16 values (integer division)

Parameters

a
Uint16Type Dividend
b
Uint16Type Divisor

Returns

Uint16Type Quotient (floor(a / b))

See

https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation

Since

0.0.0

Throws

If divisor is zero

Example


equals()

equals(a, b): boolean
Defined in: src/primitives/Uint16/equals.js:18 Check if two Uint16 values are equal

Parameters

a
Uint16Type First operand
b
Uint16Type Second operand

Returns

boolean true if a === b

See

https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation

Since

0.0.0

Throws

Example


from()

from(value): Uint16Type
Defined in: src/primitives/Uint16/from.js:19 Create Uint16 from number or string

Parameters

value
number or decimal/hex string string | number

Returns

Uint16Type Uint16 value

See

https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation

Since

0.0.0

Throws

If value is out of range or invalid

Example


fromBigint()

fromBigint(value): Uint16Type
Defined in: src/primitives/Uint16/fromBigint.js:17 Create Uint16 from bigint

Parameters

value
bigint bigint value

Returns

Uint16Type Uint16 value

See

https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation

Since

0.0.0

Throws

If value is out of range

Example


fromBytes()

fromBytes(bytes): Uint16Type
Defined in: src/primitives/Uint16/fromBytes.js:16 Create Uint16 from Uint8Array (2 bytes, big-endian)

Parameters

bytes
Uint8Array<ArrayBufferLike> Uint8Array (must be exactly 2 bytes)

Returns

Uint16Type Uint16 value

See

https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation

Since

0.0.0

Throws

If bytes length is not 2

Example


fromHex()

fromHex(hex): Uint16Type
Defined in: src/primitives/Uint16/fromHex.js:18 Create Uint16 from hex string

Parameters

hex
string hex string (with or without 0x prefix)

Returns

Uint16Type Uint16 value

See

https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation

Since

0.0.0

Throws

If hex is invalid or out of range

Example


fromNumber()

fromNumber(value): Uint16Type
Defined in: src/primitives/Uint16/fromNumber.js:17 Create Uint16 from number

Parameters

value
number number value

Returns

Uint16Type Uint16 value

See

https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation

Since

0.0.0

Throws

If value is out of range or not an integer

Example


greaterThan()

greaterThan(a, b): boolean
Defined in: src/primitives/Uint16/greaterThan.js:18 Check if first Uint16 is greater than second

Parameters

a
Uint16Type First operand
b
Uint16Type Second operand

Returns

boolean true if a > b

See

https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation

Since

0.0.0

Throws

Example


isValid()

isValid(value): value is Uint16Type
Defined in: src/primitives/Uint16/isValid.js:21 Check if value is a valid Uint16

Parameters

value
unknown Value to check

Returns

value is Uint16Type true if valid Uint16

See

https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation

Since

0.0.0

Throws

Example


isZero()

isZero(uint): boolean
Defined in: src/primitives/Uint16/isZero.js:18 Check if Uint16 value is zero

Parameters

uint
Uint16Type Uint16 value

Returns

boolean true if uint === 0

See

https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation

Since

0.0.0

Throws

Example


leadingZeros()

leadingZeros(uint): number
Defined in: src/primitives/Uint16/leadingZeros.js:18 Count leading zero bits in Uint16 value

Parameters

uint
Uint16Type Input value

Returns

number Number of leading zero bits (0-16)

See

https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation

Since

0.0.0

Throws

Example


lessThan()

lessThan(a, b): boolean
Defined in: src/primitives/Uint16/lessThan.js:18 Check if first Uint16 is less than second

Parameters

a
Uint16Type First operand
b
Uint16Type Second operand

Returns

boolean true if a < b

See

https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation

Since

0.0.0

Throws

Example


maximum()

maximum(a, b): Uint16Type
Defined in: src/primitives/Uint16/maximum.js:18 Return maximum of two Uint16 values

Parameters

a
Uint16Type First operand
b
Uint16Type Second operand

Returns

Uint16Type Maximum value

See

https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation

Since

0.0.0

Throws

Example


minimum()

minimum(a, b): Uint16Type
Defined in: src/primitives/Uint16/minimum.js:18 Return minimum of two Uint16 values

Parameters

a
Uint16Type First operand
b
Uint16Type Second operand

Returns

Uint16Type Minimum value

See

https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation

Since

0.0.0

Throws

Example


minus()

minus(a, b): Uint16Type
Defined in: src/primitives/Uint16/minus.js:18 Subtract two Uint16 values with underflow checking

Parameters

a
Uint16Type First operand
b
Uint16Type Second operand

Returns

Uint16Type Difference (a - b)

See

https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation

Since

0.0.0

Throws

If result is negative

Example


modulo()

modulo(a, b): Uint16Type
Defined in: src/primitives/Uint16/modulo.js:18 Compute modulo of two Uint16 values

Parameters

a
Uint16Type Dividend
b
Uint16Type Divisor

Returns

Uint16Type Remainder (a % b)

See

https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation

Since

0.0.0

Throws

If divisor is zero

Example


plus()

plus(a, b): Uint16Type
Defined in: src/primitives/Uint16/plus.js:20 Add two Uint16 values with overflow checking

Parameters

a
Uint16Type First operand
b
Uint16Type Second operand

Returns

Uint16Type Sum (a + b)

See

https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation

Since

0.0.0

Throws

If result exceeds maximum value

Example


popCount()

popCount(uint): number
Defined in: src/primitives/Uint16/popCount.js:17 Count number of set bits (population count) in Uint16 value

Parameters

uint
Uint16Type Input value

Returns

number Number of set bits (0-16)

See

https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation

Since

0.0.0

Throws

Example


shiftLeft()

shiftLeft(uint, shift): Uint16Type
Defined in: src/primitives/Uint16/shiftLeft.js:19 Left shift Uint16 value

Parameters

uint
Uint16Type Value to shift
shift
number Number of bits to shift (0-15)

Returns

Uint16Type Left-shifted value (masked to 16 bits)

See

https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation

Since

0.0.0

Throws

Example


shiftRight()

shiftRight(uint, shift): Uint16Type
Defined in: src/primitives/Uint16/shiftRight.js:17 Right shift Uint16 value (logical shift)

Parameters

uint
Uint16Type Value to shift
shift
number Number of bits to shift (0-15)

Returns

Uint16Type Right-shifted value

See

https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation

Since

0.0.0

Throws

Example


times()

times(a, b): Uint16Type
Defined in: src/primitives/Uint16/times.js:20 Multiply two Uint16 values with overflow checking

Parameters

a
Uint16Type First operand
b
Uint16Type Second operand

Returns

Uint16Type Product (a * b)

See

https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation

Since

0.0.0

Throws

If result exceeds maximum value

Example


toBigint()

toBigint(uint): bigint
Defined in: src/primitives/Uint16/toBigint.js:16 Convert Uint16 to bigint

Parameters

uint
Uint16Type Uint16 value

Returns

bigint bigint value

See

https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation

Since

0.0.0

Throws

Example


toBytes()

toBytes(uint): Uint8Array<ArrayBufferLike>
Defined in: src/primitives/Uint16/toBytes.js:16 Convert Uint16 to Uint8Array (2 bytes, big-endian)

Parameters

uint
Uint16Type Uint16 value

Returns

Uint8Array<ArrayBufferLike> Uint8Array of length 2

See

https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation

Since

0.0.0

Throws

Example


toHex()

toHex(uint, padded?): string
Defined in: src/primitives/Uint16/toHex.js:21 Convert Uint16 to hex string

Parameters

uint
Uint16Type Uint16 value
padded?
boolean = true Whether to pad to 4 characters (2 bytes)

Returns

string Hex string with 0x prefix

See

https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation

Since

0.0.0

Throws

Example


toNumber()

toNumber(uint): number
Defined in: src/primitives/Uint16/toNumber.js:16 Convert Uint16 to number

Parameters

uint
Uint16Type Uint16 value

Returns

number number value

See

https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation

Since

0.0.0

Throws

Example


toString()

toString(uint): string
Defined in: src/primitives/Uint16/toString.js:17 Convert Uint16 to decimal string

Parameters

uint
Uint16Type Uint16 value

Returns

string Decimal string representation

See

https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentation

Since

0.0.0

Throws

Example