升級
promote 指令用於將 f32 型別數字轉換為 f64 型別(提升)。
試一試
(module
(import "console" "log" (func $log (param f64)))
(func $main
f32.const 10.5 ;; push an f32 onto the stack
f64.promote_f32 ;; promote from f32 to f64
call $log ;; log the result
)
(start $main)
)
const url = "{%wasm-url%}";
await WebAssembly.instantiateStreaming(fetch(url), { console });
語法
wat
;; push an f32 onto the stack
f32.const 10.5
;; promote from f32 to f64
f64.promote_f32
;; the top item on the stack will now be the value 10.5 of type f64
| 指令 | 二進位制操作碼 |
|---|---|
f64.promote_f32 |
0xbb |