i32.trunc_sat_f64_s
Pops a f64 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 a signed integer (can be negative). Any decimal parts of the number will be lost. The value must exist within the range -2147483648 to +2147483647 (2^31). 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_f64_s

Stack In

f64 The value to be converted.

Stack Out

i32 The i32 version of the f64 value.

Examples

;; Convert f64 1234.567 into an i32 value
f64.const 1234.567
i32.trunc_sat_f64_s

;; The stack contains an i32 value of 1234
;; Convert f64 -3.142 into an i32 value
f64.const -3.142
i32.trunc_sat_f64_s

;; The stack contains an i32 value of -3
;; Convert f64 2200000000 into an i32 value
f64.const 2200000000
i32.trunc_sat_f64_s

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