向上取整
ceil 指令用於獲取向上舍入到下一個整數的數字值。
試一試
(module
(import "console" "log" (func $log (param f32)))
(func $main
f32.const 2.7 ;; load a number onto the stack
f32.ceil ;; round up
call $log ;; log the result
)
(start $main)
)
const url = "{%wasm-url%}";
await WebAssembly.instantiateStreaming(fetch(url), { console });
語法
wat
;; load a number onto the stack
f32.const 2.7
;; round up
f32.ceil
;; the top item on the stack will now be 3
| 指令 | 二進位制操作碼 |
|---|---|
f32.ceil |
0x8d |
f64.ceil |
0x9b |