@tevm/voltaire / primitives/Uint16
primitives/Uint16
Variables
MAX
Defined in: src/primitives/Uint16/constants.js:12constMAX:Uint16Type
MIN
Defined in: src/primitives/Uint16/constants.js:9constMIN:Uint16Type
ONE
Defined in: src/primitives/Uint16/constants.js:18constONE:Uint16Type
SIZE
Defined in: src/primitives/Uint16/constants.js:21constSIZE:number=16
Uint16Type
Defined in: src/primitives/Uint16/index.ts:72constUint16Type:object
Type Declaration
bitLength()
bitLength: (Get bit length of Uint16 value (position of highest set bit)uint) =>number
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 documentationSince
0.0.0Throws
Example
bitwiseAnd()
bitwiseAnd: (Bitwise AND of two Uint16 valuesa,b) =>Uint16Type
Parameters
a
Uint16Type
First operand
b
Uint16Type
Second operand
Returns
Uint16Type
Bitwise AND result
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
Example
bitwiseNot()
bitwiseNot: (Bitwise NOT of Uint16 valueuint) =>Uint16Type
Parameters
uint
Uint16Type
Input value
Returns
Uint16Type
Bitwise NOT result
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
Example
bitwiseOr()
bitwiseOr: (Bitwise OR of two Uint16 valuesa,b) =>Uint16Type
Parameters
a
Uint16Type
First operand
b
Uint16Type
Second operand
Returns
Uint16Type
Bitwise OR result
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
Example
bitwiseXor()
bitwiseXor: (Bitwise XOR of two Uint16 valuesa,b) =>Uint16Type
Parameters
a
Uint16Type
First operand
b
Uint16Type
Second operand
Returns
Uint16Type
Bitwise XOR result
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
Example
dividedBy()
dividedBy: (Divide two Uint16 values (integer division)a,b) =>Uint16Type
Parameters
a
Uint16Type
Dividend
b
Uint16Type
Divisor
Returns
Uint16Type
Quotient (floor(a / b))
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
If divisor is zeroExample
equals()
equals: (Check if two Uint16 values are equala,b) =>boolean
Parameters
a
Uint16Type
First operand
b
Uint16Type
Second operand
Returns
boolean
true if a === b
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
Example
from()
from: (Create Uint16 from number or stringvalue) =>Uint16Type
Parameters
value
number or decimal/hex stringstring | number
Returns
Uint16Type
Uint16 value
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
If value is out of range or invalidExample
fromBigint()
fromBigint: (Create Uint16 from bigintvalue) =>Uint16Type
Parameters
value
bigint
bigint value
Returns
Uint16Type
Uint16 value
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
If value is out of rangeExample
fromBytes()
fromBytes: (Create Uint16 from Uint8Array (2 bytes, big-endian)bytes) =>Uint16Type
Parameters
bytes
Uint8Array<ArrayBufferLike>
Uint8Array (must be exactly 2 bytes)
Returns
Uint16Type
Uint16 value
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
If bytes length is not 2Example
fromHex()
fromHex: (Create Uint16 from hex stringhex) =>Uint16Type
Parameters
hex
string
hex string (with or without 0x prefix)
Returns
Uint16Type
Uint16 value
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
If hex is invalid or out of rangeExample
fromNumber()
fromNumber: (Create Uint16 from numbervalue) =>Uint16Type
Parameters
value
number
number value
Returns
Uint16Type
Uint16 value
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
If value is out of range or not an integerExample
greaterThan()
greaterThan: (Check if first Uint16 is greater than seconda,b) =>boolean
Parameters
a
Uint16Type
First operand
b
Uint16Type
Second operand
Returns
boolean
true if a > b
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
Example
isValid()
isValid: (Check if value is a valid Uint16value) =>value is Uint16Type
Parameters
value
unknown
Value to check
Returns
value is Uint16Type
true if valid Uint16
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
Example
isZero()
isZero: (Check if Uint16 value is zerouint) =>boolean
Parameters
uint
Uint16Type
Uint16 value
Returns
boolean
true if uint === 0
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
Example
leadingZeros()
leadingZeros: (Count leading zero bits in Uint16 valueuint) =>number
Parameters
uint
Uint16Type
Input value
Returns
number
Number of leading zero bits (0-16)
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
Example
lessThan()
lessThan: (Check if first Uint16 is less than seconda,b) =>boolean
Parameters
a
Uint16Type
First operand
b
Uint16Type
Second operand
Returns
boolean
true if a < b
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
Example
MAX
MAX: Uint16Type
maximum()
maximum: (Return maximum of two Uint16 valuesa,b) =>Uint16Type
Parameters
a
Uint16Type
First operand
b
Uint16Type
Second operand
Returns
Uint16Type
Maximum value
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
Example
MIN
MIN: Uint16Type
minimum()
minimum: (Return minimum of two Uint16 valuesa,b) =>Uint16Type
Parameters
a
Uint16Type
First operand
b
Uint16Type
Second operand
Returns
Uint16Type
Minimum value
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
Example
minus()
minus: (Subtract two Uint16 values with underflow checkinga,b) =>Uint16Type
Parameters
a
Uint16Type
First operand
b
Uint16Type
Second operand
Returns
Uint16Type
Difference (a - b)
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
If result is negativeExample
modulo()
modulo: (Compute modulo of two Uint16 valuesa,b) =>Uint16Type
Parameters
a
Uint16Type
Dividend
b
Uint16Type
Divisor
Returns
Uint16Type
Remainder (a % b)
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
If divisor is zeroExample
ONE
ONE: Uint16Type
plus()
plus: (Add two Uint16 values with overflow checkinga,b) =>Uint16Type
Parameters
a
Uint16Type
First operand
b
Uint16Type
Second operand
Returns
Uint16Type
Sum (a + b)
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
If result exceeds maximum valueExample
popCount()
popCount: (Count number of set bits (population count) in Uint16 valueuint) =>number
Parameters
uint
Uint16Type
Input value
Returns
number
Number of set bits (0-16)
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
Example
shiftLeft()
shiftLeft: (Left shift Uint16 valueuint,shift) =>Uint16Type
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 documentationSince
0.0.0Throws
Example
shiftRight()
shiftRight: (Right shift Uint16 value (logical shift)uint,shift) =>Uint16Type
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 documentationSince
0.0.0Throws
Example
SIZE
SIZE: number
times()
times: (Multiply two Uint16 values with overflow checkinga,b) =>Uint16Type
Parameters
a
Uint16Type
First operand
b
Uint16Type
Second operand
Returns
Uint16Type
Product (a * b)
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
If result exceeds maximum valueExample
toBigint()
toBigint: (Convert Uint16 to bigintuint) =>bigint
Parameters
uint
Uint16Type
Uint16 value
Returns
bigint
bigint value
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
Example
toBytes()
toBytes: (Convert Uint16 to Uint8Array (2 bytes, big-endian)uint) =>Uint8Array<ArrayBufferLike>
Parameters
uint
Uint16Type
Uint16 value
Returns
Uint8Array<ArrayBufferLike>
Uint8Array of length 2
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
Example
toHex()
toHex: (Convert Uint16 to hex stringuint,padded?) =>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 documentationSince
0.0.0Throws
Example
toNumber()
toNumber: (Convert Uint16 to numberuint) =>number
Parameters
uint
Uint16Type
Uint16 value
Returns
number
number value
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
Example
toString()
toString: (Convert Uint16 to decimal stringuint) =>string
Parameters
uint
Uint16Type
Uint16 value
Returns
string
Decimal string representation
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
Example
ZERO
ZERO: Uint16Type
ZERO
Defined in: src/primitives/Uint16/constants.js:15constZERO:Uint16Type
Functions
bitLength()
bitLength(Defined in: src/primitives/Uint16/bitLength.js:18 Get bit length of Uint16 value (position of highest set bit)uint):number
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 documentationSince
0.0.0Throws
Example
bitwiseAnd()
bitwiseAnd(Defined in: src/primitives/Uint16/bitwiseAnd.js:18 Bitwise AND of two Uint16 valuesa,b):Uint16Type
Parameters
a
Uint16Type
First operand
b
Uint16Type
Second operand
Returns
Uint16Type
Bitwise AND result
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
Example
bitwiseNot()
bitwiseNot(Defined in: src/primitives/Uint16/bitwiseNot.js:18 Bitwise NOT of Uint16 valueuint):Uint16Type
Parameters
uint
Uint16Type
Input value
Returns
Uint16Type
Bitwise NOT result
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
Example
bitwiseOr()
bitwiseOr(Defined in: src/primitives/Uint16/bitwiseOr.js:18 Bitwise OR of two Uint16 valuesa,b):Uint16Type
Parameters
a
Uint16Type
First operand
b
Uint16Type
Second operand
Returns
Uint16Type
Bitwise OR result
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
Example
bitwiseXor()
bitwiseXor(Defined in: src/primitives/Uint16/bitwiseXor.js:18 Bitwise XOR of two Uint16 valuesa,b):Uint16Type
Parameters
a
Uint16Type
First operand
b
Uint16Type
Second operand
Returns
Uint16Type
Bitwise XOR result
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
Example
dividedBy()
dividedBy(Defined in: src/primitives/Uint16/dividedBy.js:18 Divide two Uint16 values (integer division)a,b):Uint16Type
Parameters
a
Uint16Type
Dividend
b
Uint16Type
Divisor
Returns
Uint16Type
Quotient (floor(a / b))
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
If divisor is zeroExample
equals()
equals(Defined in: src/primitives/Uint16/equals.js:18 Check if two Uint16 values are equala,b):boolean
Parameters
a
Uint16Type
First operand
b
Uint16Type
Second operand
Returns
boolean
true if a === b
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
Example
from()
from(Defined in: src/primitives/Uint16/from.js:19 Create Uint16 from number or stringvalue):Uint16Type
Parameters
value
number or decimal/hex stringstring | number
Returns
Uint16Type
Uint16 value
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
If value is out of range or invalidExample
fromBigint()
fromBigint(Defined in: src/primitives/Uint16/fromBigint.js:17 Create Uint16 from bigintvalue):Uint16Type
Parameters
value
bigint
bigint value
Returns
Uint16Type
Uint16 value
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
If value is out of rangeExample
fromBytes()
fromBytes(Defined in: src/primitives/Uint16/fromBytes.js:16 Create Uint16 from Uint8Array (2 bytes, big-endian)bytes):Uint16Type
Parameters
bytes
Uint8Array<ArrayBufferLike>
Uint8Array (must be exactly 2 bytes)
Returns
Uint16Type
Uint16 value
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
If bytes length is not 2Example
fromHex()
fromHex(Defined in: src/primitives/Uint16/fromHex.js:18 Create Uint16 from hex stringhex):Uint16Type
Parameters
hex
string
hex string (with or without 0x prefix)
Returns
Uint16Type
Uint16 value
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
If hex is invalid or out of rangeExample
fromNumber()
fromNumber(Defined in: src/primitives/Uint16/fromNumber.js:17 Create Uint16 from numbervalue):Uint16Type
Parameters
value
number
number value
Returns
Uint16Type
Uint16 value
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
If value is out of range or not an integerExample
greaterThan()
greaterThan(Defined in: src/primitives/Uint16/greaterThan.js:18 Check if first Uint16 is greater than seconda,b):boolean
Parameters
a
Uint16Type
First operand
b
Uint16Type
Second operand
Returns
boolean
true if a > b
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
Example
isValid()
isValid(Defined in: src/primitives/Uint16/isValid.js:21 Check if value is a valid Uint16value):value is Uint16Type
Parameters
value
unknown
Value to check
Returns
value is Uint16Type
true if valid Uint16
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
Example
isZero()
isZero(Defined in: src/primitives/Uint16/isZero.js:18 Check if Uint16 value is zerouint):boolean
Parameters
uint
Uint16Type
Uint16 value
Returns
boolean
true if uint === 0
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
Example
leadingZeros()
leadingZeros(Defined in: src/primitives/Uint16/leadingZeros.js:18 Count leading zero bits in Uint16 valueuint):number
Parameters
uint
Uint16Type
Input value
Returns
number
Number of leading zero bits (0-16)
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
Example
lessThan()
lessThan(Defined in: src/primitives/Uint16/lessThan.js:18 Check if first Uint16 is less than seconda,b):boolean
Parameters
a
Uint16Type
First operand
b
Uint16Type
Second operand
Returns
boolean
true if a < b
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
Example
maximum()
maximum(Defined in: src/primitives/Uint16/maximum.js:18 Return maximum of two Uint16 valuesa,b):Uint16Type
Parameters
a
Uint16Type
First operand
b
Uint16Type
Second operand
Returns
Uint16Type
Maximum value
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
Example
minimum()
minimum(Defined in: src/primitives/Uint16/minimum.js:18 Return minimum of two Uint16 valuesa,b):Uint16Type
Parameters
a
Uint16Type
First operand
b
Uint16Type
Second operand
Returns
Uint16Type
Minimum value
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
Example
minus()
minus(Defined in: src/primitives/Uint16/minus.js:18 Subtract two Uint16 values with underflow checkinga,b):Uint16Type
Parameters
a
Uint16Type
First operand
b
Uint16Type
Second operand
Returns
Uint16Type
Difference (a - b)
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
If result is negativeExample
modulo()
modulo(Defined in: src/primitives/Uint16/modulo.js:18 Compute modulo of two Uint16 valuesa,b):Uint16Type
Parameters
a
Uint16Type
Dividend
b
Uint16Type
Divisor
Returns
Uint16Type
Remainder (a % b)
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
If divisor is zeroExample
plus()
plus(Defined in: src/primitives/Uint16/plus.js:20 Add two Uint16 values with overflow checkinga,b):Uint16Type
Parameters
a
Uint16Type
First operand
b
Uint16Type
Second operand
Returns
Uint16Type
Sum (a + b)
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
If result exceeds maximum valueExample
popCount()
popCount(Defined in: src/primitives/Uint16/popCount.js:17 Count number of set bits (population count) in Uint16 valueuint):number
Parameters
uint
Uint16Type
Input value
Returns
number
Number of set bits (0-16)
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
Example
shiftLeft()
shiftLeft(Defined in: src/primitives/Uint16/shiftLeft.js:19 Left shift Uint16 valueuint,shift):Uint16Type
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 documentationSince
0.0.0Throws
Example
shiftRight()
shiftRight(Defined in: src/primitives/Uint16/shiftRight.js:17 Right shift Uint16 value (logical shift)uint,shift):Uint16Type
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 documentationSince
0.0.0Throws
Example
times()
times(Defined in: src/primitives/Uint16/times.js:20 Multiply two Uint16 values with overflow checkinga,b):Uint16Type
Parameters
a
Uint16Type
First operand
b
Uint16Type
Second operand
Returns
Uint16Type
Product (a * b)
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
If result exceeds maximum valueExample
toBigint()
toBigint(Defined in: src/primitives/Uint16/toBigint.js:16 Convert Uint16 to bigintuint):bigint
Parameters
uint
Uint16Type
Uint16 value
Returns
bigint
bigint value
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
Example
toBytes()
toBytes(Defined in: src/primitives/Uint16/toBytes.js:16 Convert Uint16 to Uint8Array (2 bytes, big-endian)uint):Uint8Array<ArrayBufferLike>
Parameters
uint
Uint16Type
Uint16 value
Returns
Uint8Array<ArrayBufferLike>
Uint8Array of length 2
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
Example
toHex()
toHex(Defined in: src/primitives/Uint16/toHex.js:21 Convert Uint16 to hex stringuint,padded?):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 documentationSince
0.0.0Throws
Example
toNumber()
toNumber(Defined in: src/primitives/Uint16/toNumber.js:16 Convert Uint16 to numberuint):number
Parameters
uint
Uint16Type
Uint16 value
Returns
number
number value
See
https://voltaire.tevm.sh/primitives/uint16 for Uint16 documentationSince
0.0.0Throws
Example
toString()
toString(Defined in: src/primitives/Uint16/toString.js:17 Convert Uint16 to decimal stringuint):string
Parameters
uint
Uint16Type
Uint16 value
Returns
string
Decimal string representation

