trunc_sat_f32x4_s: Wasm SIMD conversion instruction
The trunc_sat_f32x4_s SIMD conversion instruction performs a saturating conversion of the lanes of a v128 f32x4 value interpretation into a signed i32x4 value interpretation.
If any input lane is a NaN, the resulting output lane is set to 0. If the rounded integer value of a lane is outside the range of the destination type, the result is saturated to the nearest representable integer value.
Try it
(module
(import "console" "log" (func $log (param i32)))
(func $main
v128.const f32x4 1300.5 60.4 0.5 780000.4
i32x4.trunc_sat_f32x4_s
i32x4.extract_lane 2
call $log ;; log the result
)
(start $main)
)
WebAssembly.instantiateStreaming(fetch("{%wasm-url%}"), { console });
Syntax
value_type.trunc_sat_f32x4_s
value_type-
The type of value the instruction is being run on. The following
v128value interpretations supporttrunc_sat_f32x4_s:i32x4
trunc_sat_f32x4_s-
The
trunc_sat_f32x4_sinstruction. Must always be included after thevalue_typeand a period (.).
Type
[input] -> [output]
Binary encoding
| Instruction | Binary format | Example text => binary |
|---|---|---|
i32x4.trunc_sat_f32x4_s |
0xfd 248:u32 |
i32x4.trunc_sat_f32x4_s => 0xfd 0xf8 0x01 |