Movatterモバイル変換


[0]ホーム

URL:


  1. WebAssembly
  2. Reference
  3. WebAssembly numeric instructions
  4. nearest

nearest: Wasm text instruction

Thenearest instructions are used for getting the value of a number rounded to the nearest integer.

Try it

(module  (import "console" "log" (func $log (param f32)))  (func $main    f32.const 2.7 ;; load a number onto the stack    f32.nearest ;; round to the nearest integer    call $log ;; log the result  )  (start $main))
const url = "{%wasm-url%}";await WebAssembly.instantiateStreaming(fetch(url), { console });

Syntax

wat
;; load a number onto the stackf32.const -2.7;; round to the nearest integerf32.nearest;; the top item on the stack will now be -3
InstructionBinary opcode
f32.nearest0x90
f64.nearest0x9e

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp