i32.trunc_sat_f32_u
Pops a f32 value off the stack, converts it into an i32 value, and then pushes it back on to the stack. This looks at the i32 value as an unsigned integer (positive value only). Any decimal parts of the number will be lost. The value must exist within the range 0 to 4294967296 (2^32). If the value is outside this range then, instead of throwning a runtime error, it sets the resulting value to the upper or lower limit.

Syntax

i32.trunc_sat_f32_u

Stack In

f32 The value to be converted.

Stack Out

i32 The i32 version of the f32 value.

Examples

;; Convert f32 1234.567 into an i32 value
f32.const 1234.567
i32.trunc_sat_f32_u

;; The stack contains an i32 value of 1234
;; Convert f32 2200000000 into an i32 value
f32.const 2200000000
i32.trunc_sat_f32_u

;; The stack contains an i32 value of 2200000000
;; Convert f32 -3.142 into an i32 value
f32.const -3.142
i32.trunc_sat_f32_u

;; The stack contains an i32 value of 0 (lower limit)
;; Convert f32 5000000000 into an i32 value
f32.const 5000000000
i32.trunc_sat_f32_u

;; The stack contains an i32 value of 4294967296 (upper limit)