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

View in English Always switch to English

demote: Wasm-Zahlenanweisung

Die demote-Zahlenanweisung wird verwendet, um Zahlen vom Typ f64 in den Typ f32 umzuwandeln (herabzustufen).

Probieren Sie es aus

(module
  (import "console" "log" (func $log (param f32)))
  (func $main

    f64.const 10.5 ;; push an f64 onto the stack

    f32.demote_f64 ;; demote from f64 to f32

    call $log ;; log the result

  )
  (start $main)
)
const url = "{%wasm-url%}";
await WebAssembly.instantiateStreaming(fetch(url), { console });

Syntax

wat
;; push an f64 onto the stack
f64.const 10.5

;; demote from f64 to f32
f32.demote_f64

;; the top item on the stack will now be the value 10.5 of type f32
Anweisung Binäre Opcode
f32.demote_f64 0xb6

Spezifikationen

Spezifikation
WebAssembly Core Specification
# numeric-instructions%E2%91%A8

Browser-Kompatibilität