@tevm/voltaire / primitives/Int32
primitives/Int32
Type Aliases
BrandedInt32
BrandedInt32 =Defined in: src/primitives/Int32/Int32Type.ts:25 A signed 32-bit integer branded type. Internally a JavaScript number constrained to [-2147483648, 2147483647].number&object
Type Declaration
[brand]
readonly[brand]:"Int32"
Variables
INT32_MAX
Defined in: src/primitives/Int32/Int32Type.ts:30constINT32_MAX:2147483647=2147483647
INT32_MIN
Defined in: src/primitives/Int32/Int32Type.ts:29constINT32_MIN:-2147483648=-2147483648
MAX
Defined in: src/primitives/Int32/constants.js:11constMAX:2147483647
MIN
Defined in: src/primitives/Int32/constants.js:8constMIN:-2147483648
MINUS_ONE
Defined in: src/primitives/Int32/constants.js:20constMINUS_ONE:-1
ONE
Defined in: src/primitives/Int32/constants.js:17constONE:1
SIZE
Defined in: src/primitives/Int32/constants.js:23constSIZE:4=4
ZERO
Defined in: src/primitives/Int32/constants.js:14constZERO:0
Functions
abs()
abs(Defined in: src/primitives/Int32/abs.js:8 Get absolute value of Int32value):BrandedInt32
Parameters
value
BrandedInt32
Value
Returns
BrandedInt32
Absolute value
Throws
If value is MIN (abs would overflow)bitwiseAnd()
bitwiseAnd(Defined in: src/primitives/Int32/bitwiseAnd.js:8 Bitwise AND of two Int32 valuesa,b):BrandedInt32
Parameters
a
BrandedInt32
First value
b
BrandedInt32
Second value
Returns
BrandedInt32
Result
bitwiseNot()
bitwiseNot(Defined in: src/primitives/Int32/bitwiseNot.js:7 Bitwise NOT of Int32 valuevalue):BrandedInt32
Parameters
value
BrandedInt32
Value
Returns
BrandedInt32
Result
bitwiseOr()
bitwiseOr(Defined in: src/primitives/Int32/bitwiseOr.js:8 Bitwise OR of two Int32 valuesa,b):BrandedInt32
Parameters
a
BrandedInt32
First value
b
BrandedInt32
Second value
Returns
BrandedInt32
Result
bitwiseXor()
bitwiseXor(Defined in: src/primitives/Int32/bitwiseXor.js:8 Bitwise XOR of two Int32 valuesa,b):BrandedInt32
Parameters
a
BrandedInt32
First value
b
BrandedInt32
Second value
Returns
BrandedInt32
Result
clone()
clone(Defined in: src/primitives/Int32/clone.js:7 Clone Int32 valuevalue):BrandedInt32
Parameters
value
BrandedInt32
Value to clone
Returns
BrandedInt32
Cloned value
dividedBy()
dividedBy(Defined in: src/primitives/Int32/dividedBy.js:9 Divide two Int32 values (truncates toward zero)a,b):BrandedInt32
Parameters
a
BrandedInt32
Dividend
b
BrandedInt32
Divisor
Returns
BrandedInt32
Quotient
Throws
If divisor is zero or overflow occursequals()
equals(Defined in: src/primitives/Int32/equals.js:8 Check if two Int32 values are equala,b):boolean
Parameters
a
BrandedInt32
First value
b
BrandedInt32
Second value
Returns
boolean
True if equal
from()
from(Defined in: src/primitives/Int32/from.js:15 Create Int32 from various input typesvalue):BrandedInt32
Parameters
value
Value to convertstring | number | bigint
Returns
BrandedInt32
Int32 value
Throws
If value is out of rangeExample
fromBigInt()
fromBigInt(Defined in: src/primitives/Int32/fromBigInt.js:8 Create Int32 from bigintvalue):BrandedInt32
Parameters
value
bigint
BigInt to convert
Returns
BrandedInt32
Int32 value
Throws
If value is out of rangefromBytes()
fromBytes(Defined in: src/primitives/Int32/fromBytes.js:8 Create Int32 from bytes (big-endian, two’s complement)bytes):BrandedInt32
Parameters
bytes
Uint8Array<ArrayBufferLike>
Bytes to convert (up to 4 bytes)
Returns
BrandedInt32
Int32 value
Throws
If bytes length exceeds 4fromHex()
fromHex(Defined in: src/primitives/Int32/fromHex.js:8 Create Int32 from hex string (two’s complement)hex):BrandedInt32
Parameters
hex
string
Hex string (with or without 0x prefix)
Returns
BrandedInt32
Int32 value
Throws
If hex is invalid or exceeds 4 bytesfromNumber()
fromNumber(Defined in: src/primitives/Int32/fromNumber.js:8 Create Int32 from numbervalue):BrandedInt32
Parameters
value
number
Number to convert
Returns
BrandedInt32
Int32 value
Throws
If value is out of range or NaNgreaterThan()
greaterThan(Defined in: src/primitives/Int32/greaterThan.js:8 Check if first Int32 is greater than seconda,b):boolean
Parameters
a
BrandedInt32
First value
b
BrandedInt32
Second value
Returns
boolean
True if a > b
isNegative()
isNegative(Defined in: src/primitives/Int32/isNegative.js:7 Check if Int32 value is negativevalue):boolean
Parameters
value
BrandedInt32
Value
Returns
boolean
True if negative
isPositive()
isPositive(Defined in: src/primitives/Int32/isPositive.js:7 Check if Int32 value is positivevalue):boolean
Parameters
value
BrandedInt32
Value
Returns
boolean
True if positive
isValid()
isValid(Defined in: src/primitives/Int32/isValid.js:7 Check if value is a valid Int32value):boolean
Parameters
value
unknown
Value to check
Returns
boolean
True if valid Int32
isZero()
isZero(Defined in: src/primitives/Int32/isZero.js:7 Check if Int32 value is zerovalue):boolean
Parameters
value
BrandedInt32
Value
Returns
boolean
True if zero
lessThan()
lessThan(Defined in: src/primitives/Int32/lessThan.js:8 Check if first Int32 is less than seconda,b):boolean
Parameters
a
BrandedInt32
First value
b
BrandedInt32
Second value
Returns
boolean
True if a < b
maximum()
maximum(Defined in: src/primitives/Int32/maximum.js:8 Get maximum of two Int32 valuesa,b):BrandedInt32
Parameters
a
BrandedInt32
First value
b
BrandedInt32
Second value
Returns
BrandedInt32
Maximum value
minimum()
minimum(Defined in: src/primitives/Int32/minimum.js:8 Get minimum of two Int32 valuesa,b):BrandedInt32
Parameters
a
BrandedInt32
First value
b
BrandedInt32
Second value
Returns
BrandedInt32
Minimum value
minus()
minus(Defined in: src/primitives/Int32/minus.js:9 Subtract two Int32 valuesa,b):BrandedInt32
Parameters
a
BrandedInt32
First value
b
BrandedInt32
Second value
Returns
BrandedInt32
Result
Throws
If result overflowsmodulo()
modulo(Defined in: src/primitives/Int32/modulo.js:9 Compute modulo of two Int32 valuesa,b):BrandedInt32
Parameters
a
BrandedInt32
Dividend
b
BrandedInt32
Divisor
Returns
BrandedInt32
Remainder
Throws
If divisor is zeronegate()
negate(Defined in: src/primitives/Int32/negate.js:8 Negate Int32 valuevalue):BrandedInt32
Parameters
value
BrandedInt32
Value
Returns
BrandedInt32
Negated value
Throws
If value is MIN (negation would overflow)plus()
plus(Defined in: src/primitives/Int32/plus.js:9 Add two Int32 valuesa,b):BrandedInt32
Parameters
a
BrandedInt32
First value
b
BrandedInt32
Second value
Returns
BrandedInt32
Result
Throws
If result overflowsshiftLeft()
shiftLeft(Defined in: src/primitives/Int32/shiftLeft.js:8 Shift Int32 left by n bitsvalue,n):BrandedInt32
Parameters
value
BrandedInt32
Value to shift
n
number
Number of bits to shift (0-31)
Returns
BrandedInt32
Result
shiftRight()
shiftRight(Defined in: src/primitives/Int32/shiftRight.js:8 Arithmetic shift Int32 right by n bits (preserves sign)value,n):BrandedInt32
Parameters
value
BrandedInt32
Value to shift
n
number
Number of bits to shift (0-31)
Returns
BrandedInt32
Result
sign()
sign(Defined in: src/primitives/Int32/sign.js:7 Get sign of Int32 valuevalue):-1|0|1
Parameters
value
BrandedInt32
Value
Returns
-1 | 0 | 1
-1 if negative, 0 if zero, 1 if positive
times()
times(Defined in: src/primitives/Int32/times.js:9 Multiply two Int32 valuesa,b):BrandedInt32
Parameters
a
BrandedInt32
First value
b
BrandedInt32
Second value
Returns
BrandedInt32
Result
Throws
If result overflowstoBigInt()
toBigInt(Defined in: src/primitives/Int32/toBigInt.js:7 Convert Int32 to bigintvalue):bigint
Parameters
value
BrandedInt32
Int32 value
Returns
bigint
BigInt value
toBytes()
toBytes(Defined in: src/primitives/Int32/toBytes.js:7 Convert Int32 to bytes (big-endian, two’s complement, 4 bytes)value):Uint8Array<ArrayBufferLike>
Parameters
value
BrandedInt32
Int32 value
Returns
Uint8Array<ArrayBufferLike>
4-byte Uint8Array
toHex()
toHex(Defined in: src/primitives/Int32/toHex.js:7 Convert Int32 to hex string (two’s complement)value):string
Parameters
value
BrandedInt32
Int32 value
Returns
string
Hex string with 0x prefix
toNumber()
toNumber(Defined in: src/primitives/Int32/toNumber.js:7 Convert Int32 to numbervalue):number
Parameters
value
BrandedInt32
Int32 value
Returns
number
Number value
toString()
toString(Defined in: src/primitives/Int32/toString.js:8 Convert Int32 to stringvalue):string
Parameters
value
BrandedInt32
Int32 value
Returns
string
String representation
