i64: Wasm type
The i64 value type holds a 64-bit integer.
Syntax
;; Function returning an i64 constant
(func (result i64)
i64.const 9000000000
)
;; i64 parameter and local
(func (param $p i64) (local $tmp i64)
;; ...
)
;; Mutable i64 global
(global $count (mut i64) (i64.const 0))
Description
i64 values are 64 bits wide and are not inherently signed or unsigned. Each instruction chooses its interpretation: signed variants such as i64.div_s treat operands as two's-complement, whereas unsigned variants such as i64.div_u do not. Operations whose result is unaffected by signedness, such as addition, subtraction, multiplication, and bitwise operations, have a single instruction.
i64 is transparent: its bit pattern is observable, and i64 values may be stored in linear memory.
JavaScript boundary
JavaScript's Number type cannot losslessly represent the full i64 range, so i64 values cross the JavaScript boundary as BigInt. Out-of-range BigInts wrap modulo 2⁶⁴. Passing a plain Number where an i64 is expected throws a TypeError.
Specifications
| Specification |
|---|
| Unknown specification> # syntax-numtype> |