i32: Wasm type
The i32 value type holds a 32-bit integer.
Syntax
;; Function returning an i32 constant
(func (result i32)
i32.const 42
)
;; i32 parameter and local
(func (param $p i32) (local $tmp i32)
;; ...
)
;; Mutable i32 global
(global $count (mut i32) (i32.const 0))
Description
i32 values are 32 bits wide and are not inherently signed or unsigned. The interpretation is chosen by each instruction: i32.div_s for example treats its operands as two's-complement signed integers, while i32.div_u treats them as unsigned. Where the distinction does not affect the result, such as in addition, subtraction, multiplication, and bitwise operations, a single instruction handles both interpretations.
i32 is the default address type for memory and table operations. Addresses, offsets, and sizes passed to instructions such as i32.load and table.get are i32 unless a module opts into a wider address type for the memory.
i32 is transparent: its bit pattern is observable, and i32 values may be stored in linear memory.
JavaScript boundary
At the JavaScript boundary, i32 values cross as JavaScript Number values. Out-of-range JavaScript numbers wrap modulo 2³².
Specifications
| Specification |
|---|
| Unknown specification> # syntax-numtype> |