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

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

View in English Always switch to English

reinterpret: Wasm Textinstruktion

Die reinterpret Instruktionen werden verwendet, um die Bits einer Zahl als einen anderen Typ neu zu interpretieren.

Probieren Sie es aus

(module
 (import "console" "log" (func $log (param i32)))
 (func $main
 ;; the value `10000000_00000000_00000000_00000000` in binary
 ;; maps to `-0` as a floating point and to `-2147483648` as an integer.
 f32.const -0 ;; push an f32 onto the stack
 i32.reinterpret_f32 ;; reinterpret the bytes of the f32 as i32
 call $log ;; log the result
 )
 (start $main)
)
const url = "{%wasm-url%}";
await WebAssembly.instantiateStreaming(fetch(url), { console });

Syntax

wat
;; the value `10000000_00000000_00000000_00000000` in binary
;; maps to `-0` as a floating point and to `-2147483648` as an integer
;; push an f32 onto the stack
f32.const -0
;; reinterpret the bytes of the f32 as i32
i32.reinterpret_f32
;; the top item on the stack will now be the value -2147483648 of type i32
Instruktion Binärer Opcode
i32.reinterpret_f32 0xbc
i64.reinterpret_f64 0xbd
f32.reinterpret_i32 0xbe
f64.reinterpret_i64 0xbf

Help improve MDN

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

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