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

primitives/Uint8

Variables

MAX

const MAX: Uint8Type
Defined in: src/primitives/Uint8/constants.js:12

MIN

const MIN: Uint8Type
Defined in: src/primitives/Uint8/constants.js:9

ONE

const ONE: Uint8Type
Defined in: src/primitives/Uint8/constants.js:18

SIZE

const SIZE: number = 8
Defined in: src/primitives/Uint8/constants.js:21

Uint8Type

const Uint8Type: object
Defined in: src/primitives/Uint8/index.ts:72

Type Declaration

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

ZERO

const ZERO: Uint8Type
Defined in: src/primitives/Uint8/constants.js:15

Functions

bitLength()

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

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 documentation

Since

0.0.0

Throws

Example


bitwiseAnd()

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

Parameters

a
Uint8Type First operand
b
Uint8Type Second operand

Returns

Uint8Type Bitwise AND result

See

https://voltaire.tevm.sh/primitives/uint8 for Uint8 documentation

Since

0.0.0

Throws

Example


bitwiseNot()

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

Parameters

uint
Uint8Type Input value

Returns

Uint8Type Bitwise NOT result

See

https://voltaire.tevm.sh/primitives/uint8 for Uint8 documentation

Since

0.0.0

Throws

Example


bitwiseOr()

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

Parameters

a
Uint8Type First operand
b
Uint8Type Second operand

Returns

Uint8Type Bitwise OR result

See

https://voltaire.tevm.sh/primitives/uint8 for Uint8 documentation

Since

0.0.0

Throws

Example


bitwiseXor()

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

Parameters

a
Uint8Type First operand
b
Uint8Type Second operand

Returns

Uint8Type Bitwise XOR result

See

https://voltaire.tevm.sh/primitives/uint8 for Uint8 documentation

Since

0.0.0

Throws

Example


dividedBy()

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

Parameters

a
Uint8Type Dividend
b
Uint8Type Divisor

Returns

Uint8Type Quotient (floor(a / b))

See

https://voltaire.tevm.sh/primitives/uint8 for Uint8 documentation

Since

0.0.0

Throws

If divisor is zero

Example


equals()

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

Parameters

a
Uint8Type First operand
b
Uint8Type Second operand

Returns

boolean true if a === b

See

https://voltaire.tevm.sh/primitives/uint8 for Uint8 documentation

Since

0.0.0

Throws

Example


from()

from(value): Uint8Type
Defined in: src/primitives/Uint8/from.js:26 Create Uint8 from number or string

Parameters

value
number or decimal/hex string string | number

Returns

Uint8Type Uint8 value

See

https://voltaire.tevm.sh/primitives/uint8 for Uint8 documentation

Since

0.0.0

Throws

If value is not a valid integer

Throws

If value is negative

Throws

If value exceeds 255

Example


fromBigint()

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

Parameters

value
bigint bigint value

Returns

Uint8Type Uint8 value

See

https://voltaire.tevm.sh/primitives/uint8 for Uint8 documentation

Since

0.0.0

Throws

If value is out of range

Example


fromBytes()

fromBytes(bytes): Uint8Type
Defined in: src/primitives/Uint8/fromBytes.js:16 Create Uint8 from Uint8Array (single byte)

Parameters

bytes
Uint8Array<ArrayBufferLike> Uint8Array (must be exactly 1 byte)

Returns

Uint8Type Uint8 value

See

https://voltaire.tevm.sh/primitives/uint8 for Uint8 documentation

Since

0.0.0

Throws

If bytes length is not 1

Example


fromHex()

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

Parameters

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

Returns

Uint8Type Uint8 value

See

https://voltaire.tevm.sh/primitives/uint8 for Uint8 documentation

Since

0.0.0

Throws

If hex is invalid or out of range

Example


fromNumber()

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

Parameters

value
number number value

Returns

Uint8Type Uint8 value

See

https://voltaire.tevm.sh/primitives/uint8 for Uint8 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/Uint8/greaterThan.js:18 Check if first Uint8 is greater than second

Parameters

a
Uint8Type First operand
b
Uint8Type Second operand

Returns

boolean true if a > b

See

https://voltaire.tevm.sh/primitives/uint8 for Uint8 documentation

Since

0.0.0

Throws

Example


isValid()

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

Parameters

value
unknown Value to check

Returns

value is Uint8Type true if valid Uint8

See

https://voltaire.tevm.sh/primitives/uint8 for Uint8 documentation

Since

0.0.0

Throws

Example


isZero()

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

Parameters

uint
Uint8Type Uint8 value

Returns

boolean true if uint === 0

See

https://voltaire.tevm.sh/primitives/uint8 for Uint8 documentation

Since

0.0.0

Throws

Example


leadingZeros()

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

Parameters

uint
Uint8Type Input value

Returns

number Number of leading zero bits (0-8)

See

https://voltaire.tevm.sh/primitives/uint8 for Uint8 documentation

Since

0.0.0

Throws

Example


lessThan()

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

Parameters

a
Uint8Type First operand
b
Uint8Type Second operand

Returns

boolean true if a < b

See

https://voltaire.tevm.sh/primitives/uint8 for Uint8 documentation

Since

0.0.0

Throws

Example


maximum()

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

Parameters

a
Uint8Type First operand
b
Uint8Type Second operand

Returns

Uint8Type Maximum value

See

https://voltaire.tevm.sh/primitives/uint8 for Uint8 documentation

Since

0.0.0

Throws

Example


minimum()

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

Parameters

a
Uint8Type First operand
b
Uint8Type Second operand

Returns

Uint8Type Minimum value

See

https://voltaire.tevm.sh/primitives/uint8 for Uint8 documentation

Since

0.0.0

Throws

Example


minus()

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

Parameters

a
Uint8Type First operand
b
Uint8Type Second operand

Returns

Uint8Type Difference (a - b)

See

https://voltaire.tevm.sh/primitives/uint8 for Uint8 documentation

Since

0.0.0

Throws

If result is negative

Example


modulo()

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

Parameters

a
Uint8Type Dividend
b
Uint8Type Divisor

Returns

Uint8Type Remainder (a % b)

See

https://voltaire.tevm.sh/primitives/uint8 for Uint8 documentation

Since

0.0.0

Throws

If divisor is zero

Example


plus()

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

Parameters

a
Uint8Type First operand
b
Uint8Type Second operand

Returns

Uint8Type Sum (a + b)

See

https://voltaire.tevm.sh/primitives/uint8 for Uint8 documentation

Since

0.0.0

Throws

If result exceeds maximum value

Example


popCount()

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

Parameters

uint
Uint8Type Input value

Returns

number Number of set bits (0-8)

See

https://voltaire.tevm.sh/primitives/uint8 for Uint8 documentation

Since

0.0.0

Throws

Example


shiftLeft()

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

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 documentation

Since

0.0.0

Throws

Example


shiftRight()

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

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 documentation

Since

0.0.0

Throws

Example


times()

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

Parameters

a
Uint8Type First operand
b
Uint8Type Second operand

Returns

Uint8Type Product (a * b)

See

https://voltaire.tevm.sh/primitives/uint8 for Uint8 documentation

Since

0.0.0

Throws

If result exceeds maximum value

Example


toBigint()

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

Parameters

uint
Uint8Type Uint8 value

Returns

bigint bigint value

See

https://voltaire.tevm.sh/primitives/uint8 for Uint8 documentation

Since

0.0.0

Throws

Example


toBytes()

toBytes(uint): Uint8Array<ArrayBufferLike>
Defined in: src/primitives/Uint8/toBytes.js:16 Convert Uint8 to Uint8Array (1 byte)

Parameters

uint
Uint8Type Uint8 value

Returns

Uint8Array<ArrayBufferLike> Uint8Array of length 1

See

https://voltaire.tevm.sh/primitives/uint8 for Uint8 documentation

Since

0.0.0

Throws

Example


toHex()

toHex(uint, padded?): string
Defined in: src/primitives/Uint8/toHex.js:21 Convert Uint8 to hex 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 documentation

Since

0.0.0

Throws

Example


toNumber()

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

Parameters

uint
Uint8Type Uint8 value

Returns

number number value

See

https://voltaire.tevm.sh/primitives/uint8 for Uint8 documentation

Since

0.0.0

Throws

Example


toString()

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

Parameters

uint
Uint8Type Uint8 value

Returns

string Decimal string representation

See

https://voltaire.tevm.sh/primitives/uint8 for Uint8 documentation

Since

0.0.0

Throws

Example