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

primitives/Int256

Type Aliases

BrandedInt256

BrandedInt256 = bigint & object
Defined in: src/primitives/Int256/Int256Type.ts:9 Branded Int256 type (critical for EVM signed operations)

Type Declaration

[brand]
readonly [brand]: "Int256"

See

https://voltaire.tevm.sh/primitives/int256 for Int256 documentation

Since

0.0.0

Variables

BITS

const BITS: number = 256
Defined in: src/primitives/Int256/constants.js:51 Size in bits

Int256

const Int256: object
Defined in: src/primitives/Int256/index.ts:98

Type Declaration

abs()
abs: (value) => BrandedInt256
Absolute value of Int256
Parameters
value
BrandedInt256 Input value
Returns
BrandedInt256 Absolute value
See
https://voltaire.tevm.sh/primitives/int128 for Int256 documentation
Since
0.0.0
Throws
If value is MIN (abs(MIN) overflows)
Example
bitLength()
bitLength: (value) => number
Get bit length of Int256 value
Parameters
value
BrandedInt256 Input value
Returns
number Number of bits needed to represent value
See
https://voltaire.tevm.sh/primitives/int128 for Int256 documentation
Since
0.0.0
Example
BITS
BITS: number
Size in bits
bitwiseAnd()
bitwiseAnd: (a, b) => BrandedInt256
Bitwise AND of Int256 values
Parameters
a
BrandedInt256 First value
b
BrandedInt256 Second value
Returns
BrandedInt256 Result
See
https://voltaire.tevm.sh/primitives/int128 for Int256 documentation
Since
0.0.0
Example
bitwiseNot()
bitwiseNot: (value) => BrandedInt256
Bitwise NOT of Int256 value
Parameters
value
BrandedInt256 Input value
Returns
BrandedInt256 Result
See
https://voltaire.tevm.sh/primitives/int128 for Int256 documentation
Since
0.0.0
Example
bitwiseOr()
bitwiseOr: (a, b) => BrandedInt256
Bitwise OR of Int256 values
Parameters
a
BrandedInt256 First value
b
BrandedInt256 Second value
Returns
BrandedInt256 Result
See
https://voltaire.tevm.sh/primitives/int128 for Int256 documentation
Since
0.0.0
Example
bitwiseXor()
bitwiseXor: (a, b) => BrandedInt256
Bitwise XOR of Int256 values
Parameters
a
BrandedInt256 First value
b
BrandedInt256 Second value
Returns
BrandedInt256 Result
See
https://voltaire.tevm.sh/primitives/int128 for Int256 documentation
Since
0.0.0
Example
dividedBy()
dividedBy: (a, b) => BrandedInt256
Divide Int256 values (EVM SDIV - signed division, truncate toward zero) EVM SDIV semantics:
  • Truncates toward zero (not floor division)
  • -10 / 3 = -3 (not -4)
  • MIN / -1 overflows (throws error)
  • 0 / 0 throws error
Parameters
a
BrandedInt256 Dividend
b
BrandedInt256 Divisor
Returns
BrandedInt256 Quotient (truncated toward zero)
See
Since
0.0.0
Throws
If divisor is zero or MIN / -1 (overflow)
Example
equals()
equals: (a, b) => boolean
Check Int256 equality
Parameters
a
BrandedInt256 First value
b
BrandedInt256 Second value
Returns
boolean True if equal
See
https://voltaire.tevm.sh/primitives/int128 for Int256 documentation
Since
0.0.0
Example
from()
from: (value) => BrandedInt256
Create Int256 from bigint, number, or string
Parameters
value
bigint, number, or decimal/hex string string | number | bigint
Returns
BrandedInt256 Int256 value
See
https://voltaire.tevm.sh/primitives/int128 for Int256 documentation
Since
0.0.0
Throws
If value is out of range or invalid
Example
fromBigInt()
fromBigInt: (value) => BrandedInt256
Create Int256 from bigint
Parameters
value
bigint BigInt value
Returns
BrandedInt256 Int256 value
See
https://voltaire.tevm.sh/primitives/int128 for Int256 documentation
Since
0.0.0
Throws
If value is out of range
Example
fromBytes()
fromBytes: (bytes) => BrandedInt256
Create Int256 from bytes (two’s complement, big-endian)
Parameters
bytes
Uint8Array<ArrayBufferLike> Byte array (32 bytes)
Returns
BrandedInt256 Int256 value
See
https://voltaire.tevm.sh/primitives/int128 for Int256 documentation
Since
0.0.0
Throws
If bytes length is incorrect
Example
fromHex()
fromHex: (hex) => BrandedInt256
Create Int256 from hex string (two’s complement)
Parameters
hex
string Hex string (with or without 0x prefix)
Returns
BrandedInt256 Int256 value
See
https://voltaire.tevm.sh/primitives/int128 for Int256 documentation
Since
0.0.0
Throws
If hex is invalid or out of range
Example
fromNumber()
fromNumber: (value) => BrandedInt256
Create Int256 from number
Parameters
value
number Integer number
Returns
BrandedInt256 Int256 value
See
https://voltaire.tevm.sh/primitives/int128 for Int256 documentation
Since
0.0.0
Throws
If value is not an integer or out of range
Example
greaterThan()
greaterThan: (a, b) => boolean
Check if Int256 is greater than another
Parameters
a
BrandedInt256 First value
b
BrandedInt256 Second value
Returns
boolean True if a > b
See
https://voltaire.tevm.sh/primitives/int128 for Int256 documentation
Since
0.0.0
Example
isNegative()
isNegative: (value) => boolean
Check if Int256 is negative
Parameters
value
BrandedInt256 Input value
Returns
boolean True if negative
See
https://voltaire.tevm.sh/primitives/int128 for Int256 documentation
Since
0.0.0
Example
isPositive()
isPositive: (value) => boolean
Check if Int256 is positive
Parameters
value
BrandedInt256 Input value
Returns
boolean True if positive
See
https://voltaire.tevm.sh/primitives/int128 for Int256 documentation
Since
0.0.0
Example
isValid()
isValid: (value) => boolean
Check if value is valid Int256
Parameters
value
bigint Value to check
Returns
boolean True if valid Int256
See
https://voltaire.tevm.sh/primitives/int128 for Int256 documentation
Since
0.0.0
Example
isZero()
isZero: (value) => boolean
Check if Int256 is zero
Parameters
value
BrandedInt256 Input value
Returns
boolean True if zero
See
https://voltaire.tevm.sh/primitives/int128 for Int256 documentation
Since
0.0.0
Example
leadingZeros()
leadingZeros: (value) => number
Count leading zeros in Int256 two’s complement representation
Parameters
value
BrandedInt256 Input value
Returns
number Number of leading zero bits
See
https://voltaire.tevm.sh/primitives/int128 for Int256 documentation
Since
0.0.0
Example
lessThan()
lessThan: (a, b) => boolean
Check if Int256 is less than another
Parameters
a
BrandedInt256 First value
b
BrandedInt256 Second value
Returns
boolean True if a < b
See
https://voltaire.tevm.sh/primitives/int128 for Int256 documentation
Since
0.0.0
Example
MAX
MAX: bigint
Maximum Int256 value: 2^255 - 1 EVM: 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
maximum()
maximum: (a, b) => BrandedInt256
Return maximum of two Int256 values
Parameters
a
BrandedInt256 First value
b
BrandedInt256 Second value
Returns
BrandedInt256 Maximum value
See
https://voltaire.tevm.sh/primitives/int128 for Int256 documentation
Since
0.0.0
Example
MIN
MIN: bigint
Minimum Int256 value: -2^255 EVM: 0x8000000000000000000000000000000000000000000000000000000000000000
minimum()
minimum: (a, b) => BrandedInt256
Return minimum of two Int256 values
Parameters
a
BrandedInt256 First value
b
BrandedInt256 Second value
Returns
BrandedInt256 Minimum value
See
https://voltaire.tevm.sh/primitives/int128 for Int256 documentation
Since
0.0.0
Example
minus()
minus: (a, b) => BrandedInt256
Subtract Int256 values with wrapping (EVM SUB with signed interpretation)
Parameters
a
BrandedInt256 Minuend
b
BrandedInt256 Subtrahend
Returns
BrandedInt256 Difference with wrapping
See
https://voltaire.tevm.sh/primitives/int256 for Int256 documentation
Since
0.0.0
Example
modulo()
modulo: (a, b) => BrandedInt256
Modulo Int256 values (EVM SMOD - signed modulo, sign follows dividend) EVM SMOD semantics:
  • Sign of result follows dividend (first operand)
  • -10 % 3 = -1 (not 2)
  • 10 % -3 = 1 (not -2)
  • Property: a = (a/b)*b + (a%b)
Parameters
a
BrandedInt256 Dividend
b
BrandedInt256 Divisor
Returns
BrandedInt256 Remainder (sign follows dividend)
See
Since
0.0.0
Throws
If divisor is zero
Example
MODULO
MODULO: bigint
Modulo value for wrapping: 2^256
NEG_ONE
NEG_ONE: bigint
Negative one value (-1 in two’s complement) EVM: 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
negate()
negate: (value) => BrandedInt256
Negate Int256 value with wrapping
Parameters
value
BrandedInt256 Input value
Returns
BrandedInt256 Negated value with wrapping
See
https://voltaire.tevm.sh/primitives/int256 for Int256 documentation
Since
0.0.0
Example
ONE
ONE: bigint
One value
plus()
plus: (a, b) => BrandedInt256
Add Int256 values with wrapping (EVM ADD with signed interpretation)
Parameters
a
BrandedInt256 First operand
b
BrandedInt256 Second operand
Returns
BrandedInt256 Sum with wrapping
See
https://voltaire.tevm.sh/primitives/int256 for Int256 documentation
Since
0.0.0
Example
popCount()
popCount: (value) => number
Count set bits in Int256 two’s complement representation
Parameters
value
BrandedInt256 Input value
Returns
number Number of set bits
See
https://voltaire.tevm.sh/primitives/int128 for Int256 documentation
Since
0.0.0
Example
shiftLeft()
shiftLeft: (value, shift) => BrandedInt256
Shift Int256 left with wrapping
Parameters
value
BrandedInt256 Value to shift
shift
Shift amount number | bigint
Returns
BrandedInt256 Shifted value
See
https://voltaire.tevm.sh/primitives/int128 for Int256 documentation
Since
0.0.0
Example
shiftRight()
shiftRight: (value, shift) => BrandedInt256
Arithmetic right shift of Int256 (EVM SAR - sign-preserving) EVM SAR semantics:
  • Preserves sign bit during shift
  • Negative values remain negative
  • -256 >> 1 = -128 (not 128)
  • Equivalent to division by 2^shift with floor toward negative infinity
Parameters
value
BrandedInt256 Value to shift
shift
Shift amount number | bigint
Returns
BrandedInt256 Shifted value (sign-extended)
See
Since
0.0.0
Example
sign()
sign: (value) => -1 | 0 | 1
Get sign of Int256 value
Parameters
value
BrandedInt256 Input value
Returns
-1 | 0 | 1 -1 for negative, 0 for zero, 1 for positive
See
https://voltaire.tevm.sh/primitives/int128 for Int256 documentation
Since
0.0.0
Example
SIZE
SIZE: number
Size in bytes
times()
times: (a, b) => BrandedInt256
Multiply Int256 values with wrapping (EVM MUL with signed interpretation)
Parameters
a
BrandedInt256 First operand
b
BrandedInt256 Second operand
Returns
BrandedInt256 Product with wrapping
See
https://voltaire.tevm.sh/primitives/int256 for Int256 documentation
Since
0.0.0
Example
toBigInt()
toBigInt: (value) => bigint
Convert Int256 to bigint
Parameters
value
BrandedInt256 Int256 value
Returns
bigint BigInt value
See
https://voltaire.tevm.sh/primitives/int128 for Int256 documentation
Since
0.0.0
Example
toBytes()
toBytes: (value) => Uint8Array<ArrayBufferLike>
Convert Int256 to bytes (two’s complement, big-endian)
Parameters
value
BrandedInt256 Int256 value
Returns
Uint8Array<ArrayBufferLike> Byte array (32 bytes)
See
https://voltaire.tevm.sh/primitives/int128 for Int256 documentation
Since
0.0.0
Example
toHex()
toHex: (value) => string
Convert Int256 to hex string (two’s complement)
Parameters
value
BrandedInt256 Int256 value
Returns
string Hex string with 0x prefix
See
https://voltaire.tevm.sh/primitives/int128 for Int256 documentation
Since
0.0.0
Example
toNumber()
toNumber: (value) => number
Convert Int256 to number (warns on overflow)
Parameters
value
BrandedInt256 Int256 value
Returns
number Number value
See
https://voltaire.tevm.sh/primitives/int128 for Int256 documentation
Since
0.0.0
Throws
If value exceeds Number.MAX_SAFE_INTEGER or Number.MIN_SAFE_INTEGER
Example
toString()
toString: (value) => string
Convert Int256 to decimal string
Parameters
value
BrandedInt256 Int256 value
Returns
string Decimal string
See
https://voltaire.tevm.sh/primitives/int128 for Int256 documentation
Since
0.0.0
Example
ZERO
ZERO: bigint
Zero value

MAX

const MAX: bigint
Defined in: src/primitives/Int256/constants.js:20 Maximum Int256 value: 2^255 - 1 EVM: 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff

MIN

const MIN: bigint
Defined in: src/primitives/Int256/constants.js:13 Minimum Int256 value: -2^255 EVM: 0x8000000000000000000000000000000000000000000000000000000000000000

MODULO

const MODULO: bigint
Defined in: src/primitives/Int256/constants.js:57 Modulo value for wrapping: 2^256

NEG_ONE

const NEG_ONE: bigint = -1n
Defined in: src/primitives/Int256/constants.js:39 Negative one value (-1 in two’s complement) EVM: 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff

ONE

const ONE: bigint = 1n
Defined in: src/primitives/Int256/constants.js:32 One value

SIZE

const SIZE: number = 32
Defined in: src/primitives/Int256/constants.js:45 Size in bytes

ZERO

const ZERO: bigint = 0n
Defined in: src/primitives/Int256/constants.js:26 Zero value

Functions

abs()

abs(value): BrandedInt256
Defined in: src/primitives/Int256/abs.js:18 Absolute value of Int256

Parameters

value
BrandedInt256 Input value

Returns

BrandedInt256 Absolute value

See

https://voltaire.tevm.sh/primitives/int128 for Int256 documentation

Since

0.0.0

Throws

If value is MIN (abs(MIN) overflows)

Example


bitLength()

bitLength(value): number
Defined in: src/primitives/Int256/bitLength.js:17 Get bit length of Int256 value

Parameters

value
BrandedInt256 Input value

Returns

number Number of bits needed to represent value

See

https://voltaire.tevm.sh/primitives/int128 for Int256 documentation

Since

0.0.0

Example


bitwiseAnd()

bitwiseAnd(a, b): BrandedInt256
Defined in: src/primitives/Int256/bitwiseAnd.js:19 Bitwise AND of Int256 values

Parameters

a
BrandedInt256 First value
b
BrandedInt256 Second value

Returns

BrandedInt256 Result

See

https://voltaire.tevm.sh/primitives/int128 for Int256 documentation

Since

0.0.0

Example


bitwiseNot()

bitwiseNot(value): BrandedInt256
Defined in: src/primitives/Int256/bitwiseNot.js:17 Bitwise NOT of Int256 value

Parameters

value
BrandedInt256 Input value

Returns

BrandedInt256 Result

See

https://voltaire.tevm.sh/primitives/int128 for Int256 documentation

Since

0.0.0

Example


bitwiseOr()

bitwiseOr(a, b): BrandedInt256
Defined in: src/primitives/Int256/bitwiseOr.js:19 Bitwise OR of Int256 values

Parameters

a
BrandedInt256 First value
b
BrandedInt256 Second value

Returns

BrandedInt256 Result

See

https://voltaire.tevm.sh/primitives/int128 for Int256 documentation

Since

0.0.0

Example


bitwiseXor()

bitwiseXor(a, b): BrandedInt256
Defined in: src/primitives/Int256/bitwiseXor.js:19 Bitwise XOR of Int256 values

Parameters

a
BrandedInt256 First value
b
BrandedInt256 Second value

Returns

BrandedInt256 Result

See

https://voltaire.tevm.sh/primitives/int128 for Int256 documentation

Since

0.0.0

Example


dividedBy()

dividedBy(a, b): BrandedInt256
Defined in: src/primitives/Int256/dividedBy.js:32 Divide Int256 values (EVM SDIV - signed division, truncate toward zero) EVM SDIV semantics:
  • Truncates toward zero (not floor division)
  • -10 / 3 = -3 (not -4)
  • MIN / -1 overflows (throws error)
  • 0 / 0 throws error

Parameters

a
BrandedInt256 Dividend
b
BrandedInt256 Divisor

Returns

BrandedInt256 Quotient (truncated toward zero)

See

Since

0.0.0

Throws

If divisor is zero or MIN / -1 (overflow)

Example


equals()

equals(a, b): boolean
Defined in: src/primitives/Int256/equals.js:17 Check Int256 equality

Parameters

a
BrandedInt256 First value
b
BrandedInt256 Second value

Returns

boolean True if equal

See

https://voltaire.tevm.sh/primitives/int128 for Int256 documentation

Since

0.0.0

Example


from()

from(value): BrandedInt256
Defined in: src/primitives/Int256/from.js:20 Create Int256 from bigint, number, or string

Parameters

value
bigint, number, or decimal/hex string string | number | bigint

Returns

BrandedInt256 Int256 value

See

https://voltaire.tevm.sh/primitives/int128 for Int256 documentation

Since

0.0.0

Throws

If value is out of range or invalid

Example


fromBigInt()

fromBigInt(value): BrandedInt256
Defined in: src/primitives/Int256/fromBigInt.js:18 Create Int256 from bigint

Parameters

value
bigint BigInt value

Returns

BrandedInt256 Int256 value

See

https://voltaire.tevm.sh/primitives/int128 for Int256 documentation

Since

0.0.0

Throws

If value is out of range

Example


fromBytes()

fromBytes(bytes): BrandedInt256
Defined in: src/primitives/Int256/fromBytes.js:19 Create Int256 from bytes (two’s complement, big-endian)

Parameters

bytes
Uint8Array<ArrayBufferLike> Byte array (32 bytes)

Returns

BrandedInt256 Int256 value

See

https://voltaire.tevm.sh/primitives/int128 for Int256 documentation

Since

0.0.0

Throws

If bytes length is incorrect

Example


fromHex()

fromHex(hex): BrandedInt256
Defined in: src/primitives/Int256/fromHex.js:19 Create Int256 from hex string (two’s complement)

Parameters

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

Returns

BrandedInt256 Int256 value

See

https://voltaire.tevm.sh/primitives/int128 for Int256 documentation

Since

0.0.0

Throws

If hex is invalid or out of range

Example


fromNumber()

fromNumber(value): BrandedInt256
Defined in: src/primitives/Int256/fromNumber.js:18 Create Int256 from number

Parameters

value
number Integer number

Returns

BrandedInt256 Int256 value

See

https://voltaire.tevm.sh/primitives/int128 for Int256 documentation

Since

0.0.0

Throws

If value is not an integer or out of range

Example


greaterThan()

greaterThan(a, b): boolean
Defined in: src/primitives/Int256/greaterThan.js:17 Check if Int256 is greater than another

Parameters

a
BrandedInt256 First value
b
BrandedInt256 Second value

Returns

boolean True if a > b

See

https://voltaire.tevm.sh/primitives/int128 for Int256 documentation

Since

0.0.0

Example


isNegative()

isNegative(value): boolean
Defined in: src/primitives/Int256/isNegative.js:15 Check if Int256 is negative

Parameters

value
BrandedInt256 Input value

Returns

boolean True if negative

See

https://voltaire.tevm.sh/primitives/int128 for Int256 documentation

Since

0.0.0

Example


isPositive()

isPositive(value): boolean
Defined in: src/primitives/Int256/isPositive.js:15 Check if Int256 is positive

Parameters

value
BrandedInt256 Input value

Returns

boolean True if positive

See

https://voltaire.tevm.sh/primitives/int128 for Int256 documentation

Since

0.0.0

Example


isValid()

isValid(value): boolean
Defined in: src/primitives/Int256/isValid.js:17 Check if value is valid Int256

Parameters

value
bigint Value to check

Returns

boolean True if valid Int256

See

https://voltaire.tevm.sh/primitives/int128 for Int256 documentation

Since

0.0.0

Example


isZero()

isZero(value): boolean
Defined in: src/primitives/Int256/isZero.js:15 Check if Int256 is zero

Parameters

value
BrandedInt256 Input value

Returns

boolean True if zero

See

https://voltaire.tevm.sh/primitives/int128 for Int256 documentation

Since

0.0.0

Example


leadingZeros()

leadingZeros(value): number
Defined in: src/primitives/Int256/leadingZeros.js:17 Count leading zeros in Int256 two’s complement representation

Parameters

value
BrandedInt256 Input value

Returns

number Number of leading zero bits

See

https://voltaire.tevm.sh/primitives/int128 for Int256 documentation

Since

0.0.0

Example


lessThan()

lessThan(a, b): boolean
Defined in: src/primitives/Int256/lessThan.js:17 Check if Int256 is less than another

Parameters

a
BrandedInt256 First value
b
BrandedInt256 Second value

Returns

boolean True if a < b

See

https://voltaire.tevm.sh/primitives/int128 for Int256 documentation

Since

0.0.0

Example


maximum()

maximum(a, b): BrandedInt256
Defined in: src/primitives/Int256/maximum.js:17 Return maximum of two Int256 values

Parameters

a
BrandedInt256 First value
b
BrandedInt256 Second value

Returns

BrandedInt256 Maximum value

See

https://voltaire.tevm.sh/primitives/int128 for Int256 documentation

Since

0.0.0

Example


minimum()

minimum(a, b): BrandedInt256
Defined in: src/primitives/Int256/minimum.js:17 Return minimum of two Int256 values

Parameters

a
BrandedInt256 First value
b
BrandedInt256 Second value

Returns

BrandedInt256 Minimum value

See

https://voltaire.tevm.sh/primitives/int128 for Int256 documentation

Since

0.0.0

Example


minus()

minus(a, b): BrandedInt256
Defined in: src/primitives/Int256/minus.js:19 Subtract Int256 values with wrapping (EVM SUB with signed interpretation)

Parameters

a
BrandedInt256 Minuend
b
BrandedInt256 Subtrahend

Returns

BrandedInt256 Difference with wrapping

See

https://voltaire.tevm.sh/primitives/int256 for Int256 documentation

Since

0.0.0

Example


modulo()

modulo(a, b): BrandedInt256
Defined in: src/primitives/Int256/modulo.js:30 Modulo Int256 values (EVM SMOD - signed modulo, sign follows dividend) EVM SMOD semantics:
  • Sign of result follows dividend (first operand)
  • -10 % 3 = -1 (not 2)
  • 10 % -3 = 1 (not -2)
  • Property: a = (a/b)*b + (a%b)

Parameters

a
BrandedInt256 Dividend
b
BrandedInt256 Divisor

Returns

BrandedInt256 Remainder (sign follows dividend)

See

Since

0.0.0

Throws

If divisor is zero

Example


negate()

negate(value): BrandedInt256
Defined in: src/primitives/Int256/negate.js:19 Negate Int256 value with wrapping

Parameters

value
BrandedInt256 Input value

Returns

BrandedInt256 Negated value with wrapping

See

https://voltaire.tevm.sh/primitives/int256 for Int256 documentation

Since

0.0.0

Example


plus()

plus(a, b): BrandedInt256
Defined in: src/primitives/Int256/plus.js:19 Add Int256 values with wrapping (EVM ADD with signed interpretation)

Parameters

a
BrandedInt256 First operand
b
BrandedInt256 Second operand

Returns

BrandedInt256 Sum with wrapping

See

https://voltaire.tevm.sh/primitives/int256 for Int256 documentation

Since

0.0.0

Example


popCount()

popCount(value): number
Defined in: src/primitives/Int256/popCount.js:17 Count set bits in Int256 two’s complement representation

Parameters

value
BrandedInt256 Input value

Returns

number Number of set bits

See

https://voltaire.tevm.sh/primitives/int128 for Int256 documentation

Since

0.0.0

Example


shiftLeft()

shiftLeft(value, shift): BrandedInt256
Defined in: src/primitives/Int256/shiftLeft.js:18 Shift Int256 left with wrapping

Parameters

value
BrandedInt256 Value to shift
shift
Shift amount number | bigint

Returns

BrandedInt256 Shifted value

See

https://voltaire.tevm.sh/primitives/int128 for Int256 documentation

Since

0.0.0

Example


shiftRight()

shiftRight(value, shift): BrandedInt256
Defined in: src/primitives/Int256/shiftRight.js:29 Arithmetic right shift of Int256 (EVM SAR - sign-preserving) EVM SAR semantics:
  • Preserves sign bit during shift
  • Negative values remain negative
  • -256 >> 1 = -128 (not 128)
  • Equivalent to division by 2^shift with floor toward negative infinity

Parameters

value
BrandedInt256 Value to shift
shift
Shift amount number | bigint

Returns

BrandedInt256 Shifted value (sign-extended)

See

Since

0.0.0

Example


sign()

sign(value): -1 | 0 | 1
Defined in: src/primitives/Int256/sign.js:19 Get sign of Int256 value

Parameters

value
BrandedInt256 Input value

Returns

-1 | 0 | 1 -1 for negative, 0 for zero, 1 for positive

See

https://voltaire.tevm.sh/primitives/int128 for Int256 documentation

Since

0.0.0

Example


times()

times(a, b): BrandedInt256
Defined in: src/primitives/Int256/times.js:19 Multiply Int256 values with wrapping (EVM MUL with signed interpretation)

Parameters

a
BrandedInt256 First operand
b
BrandedInt256 Second operand

Returns

BrandedInt256 Product with wrapping

See

https://voltaire.tevm.sh/primitives/int256 for Int256 documentation

Since

0.0.0

Example


toBigInt()

toBigInt(value): bigint
Defined in: src/primitives/Int256/toBigInt.js:15 Convert Int256 to bigint

Parameters

value
BrandedInt256 Int256 value

Returns

bigint BigInt value

See

https://voltaire.tevm.sh/primitives/int128 for Int256 documentation

Since

0.0.0

Example


toBytes()

toBytes(value): Uint8Array<ArrayBufferLike>
Defined in: src/primitives/Int256/toBytes.js:17 Convert Int256 to bytes (two’s complement, big-endian)

Parameters

value
BrandedInt256 Int256 value

Returns

Uint8Array<ArrayBufferLike> Byte array (32 bytes)

See

https://voltaire.tevm.sh/primitives/int128 for Int256 documentation

Since

0.0.0

Example


toHex()

toHex(value): string
Defined in: src/primitives/Int256/toHex.js:19 Convert Int256 to hex string (two’s complement)

Parameters

value
BrandedInt256 Int256 value

Returns

string Hex string with 0x prefix

See

https://voltaire.tevm.sh/primitives/int128 for Int256 documentation

Since

0.0.0

Example


toNumber()

toNumber(value): number
Defined in: src/primitives/Int256/toNumber.js:16 Convert Int256 to number (warns on overflow)

Parameters

value
BrandedInt256 Int256 value

Returns

number Number value

See

https://voltaire.tevm.sh/primitives/int128 for Int256 documentation

Since

0.0.0

Throws

If value exceeds Number.MAX_SAFE_INTEGER or Number.MIN_SAFE_INTEGER

Example


toString()

toString(value): string
Defined in: src/primitives/Int256/toString.js:16 Convert Int256 to decimal string

Parameters

value
BrandedInt256 Int256 value

Returns

string Decimal string

See

https://voltaire.tevm.sh/primitives/int128 for Int256 documentation

Since

0.0.0

Example