Int64
Type-safe signed 64-bit integers with two’s complement encoding and EVM SDIV/SMOD semantics.Overview
Brandedbigint type representing signed 64-bit integers (-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807). Uses two’s complement representation for negative values and implements EVM signed division/modulo semantics.
Quick Start
- Basic Operations
- Two's Complement
- EVM Semantics
- Comparison & Sign
Two’s Complement Encoding
Negative values use two’s complement representation:| Decimal | Hex | Notes |
|---|---|---|
| 9223372036854775807 | 0x7FFFFFFFFFFFFFFF | INT64_MAX |
| 1 | 0x0000000000000001 | Positive |
| 0 | 0x0000000000000000 | Zero |
| -1 | 0xFFFFFFFFFFFFFFFF | All bits set |
| -9223372036854775808 | 0x8000000000000000 | INT64_MIN (sign bit) |
- 0 = positive
- 1 = negative
Constants
Constructors
Conversions
Arithmetic
Bitwise Operations
Validation
API Reference
Constructors
| Function | Description |
|---|---|
from(value) | Universal constructor from number, bigint, hex, or bytes |
fromNumber(n) | From JavaScript number |
fromBigInt(n) | From BigInt |
fromHex(hex) | From hex string (two’s complement) |
fromBytes(bytes) | From Uint8Array (big-endian) |
Conversions
| Function | Description |
|---|---|
toNumber(v) | To JavaScript number (may lose precision) |
toBigInt(v) | To BigInt |
toHex(v) | To hex string |
toBytes(v) | To Uint8Array (big-endian) |
toString(v) | To decimal string |
clone(v) | Create copy |
Arithmetic
| Function | Description |
|---|---|
plus(a, b) | Addition with overflow check |
minus(a, b) | Subtraction with overflow check |
times(a, b) | Multiplication with overflow check |
dividedBy(a, b) | Division (truncate toward zero) |
modulo(a, b) | Modulo (sign follows dividend) |
abs(v) | Absolute value |
negate(v) | Negate (flip sign) |
Comparison
| Function | Description |
|---|---|
equals(a, b) | Equality check |
lessThan(a, b) | Less than comparison |
greaterThan(a, b) | Greater than comparison |
minimum(a, b) | Return smaller value |
maximum(a, b) | Return larger value |
Bitwise
| Function | Description |
|---|---|
bitwiseAnd(a, b) | Bitwise AND |
bitwiseOr(a, b) | Bitwise OR |
bitwiseXor(a, b) | Bitwise XOR |
bitwiseNot(v) | Bitwise NOT |
shiftLeft(v, n) | Left shift |
shiftRight(v, n) | Arithmetic right shift |
Validation
| Function | Description |
|---|---|
isValid(v) | Check if valid Int64 |
isZero(v) | Check if zero |
isNegative(v) | Check if negative |
isPositive(v) | Check if positive |
sign(v) | Return -1, 0, or 1 |
Related
- Int8 - Signed 8-bit integers
- Int16 - Signed 16-bit integers
- Int32 - Signed 32-bit integers
- Int128 - Signed 128-bit integers
- Int256 - Signed 256-bit integers
References
- EVM SDIV - Signed division opcode
- EVM SMOD - Signed modulo opcode
- Two’s Complement - Wikipedia

