Movatterモバイル変換


[0]ホーム

URL:


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

rem: Wasm text instruction

Therem instructions, short forremainder, are used to calculate the remainder left over when one integer is divided by another integer, similar to the% operator in other languages. Therem instructions are only available for the integer types and not for the floating point types.

Try it

(module  (import "console" "log" (func $log (param i32)))  (func $main    ;; load `10` and `3` onto the stack    i32.const 10    i32.const 3    i32.rem_u ;; calculate the remainder    call $log ;; log the result  )  (start $main))
const url = "{%wasm-url%}";await WebAssembly.instantiateStreaming(fetch(url), { console });

Syntax

wat
;; load two numbers onto the stacki32.const 10i32.const 3;; calculate the remainder of dividing one number by the otheri32.rem;; the top item on the stack will now be 1 (10 % 3 = 1)
InstructionBinary opcode
i32.rem_s0x6f
i32.rem_u0x70
i64.rem_s0x81
i64.rem_u0x82

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp