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

