1. WebAssembly
  2. Reference
  3. WebAssembly numerische Anweisungen
  4. rem

Dieser Inhalt wurde automatisch aus dem Englischen übersetzt, und kann Fehler enthalten. Erfahre mehr über dieses Experiment.

View in English Always switch to English

rem: Wasm Text-Instruktion

Die rem-Instruktionen, kurz für remainder, werden verwendet, um den Rest zu berechnen, der übrig bleibt, wenn eine ganze Zahl durch eine andere ganze Zahl geteilt wird, ähnlich dem %-Operator in anderen Sprachen. Die rem-Instruktionen sind nur für die Ganzzahltypen verfügbar und nicht für die Gleitkommatypen.

Probieren Sie es aus

(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 stack
i32.const 10
i32.const 3
;; calculate the remainder of dividing one number by the other
i32.rem
;; the top item on the stack will now be 1 (10 % 3 = 1)
Instruktion Binärer Opcode
i32.rem_s 0x6f
i32.rem_u 0x70
i64.rem_s 0x81
i64.rem_u 0x82

Help improve MDN

Erfahren Sie, wie Sie beitragen können Diese Seite wurde automatisch aus dem Englischen übersetzt.

AltStyle によって変換されたページ (->オリジナル) /