Movatterモバイル変換


[0]ホーム

URL:


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

lt: Wasm text instruction

Thelt instructions, short forless than, check if a number is less than another number. If the first number is less than the second number equal1 will be pushed on to the stack, otherwise0 will be pushed on to the stack.

The integer types have separate less than instructions for signed (lt_s) and unsigned (lt_u) numbers.

Try it

(module  (import "env" "log_bool" (func $log_bool (param i32)))  (func $main    ;; load `10` and `2` onto the stack    i32.const 10    i32.const 2    i32.lt_u ;; check if `10` is less than '2'    call $log_bool ;; log the result  )  (start $main))
const url = "{%wasm-url%}";function log_bool(value) {  console.log(Boolean(value));  // Expected output: false}await WebAssembly.instantiateStreaming(fetch(url), {  env: { log_bool },});

Syntax

wat
;; load 2 numbers on to the stacklocal.get $numi32.const 2;; check if $num is less than '2'i32.lt_u;; if $num is less than the `2`, `1` will be pushed on to the stack,;; otherwise `0` will be pushed on to the stack.
InstructionBinary opcode
i32.lt_s0x48
i32.lt_u0x49
i64.lt_s0x53
i64.lt_u0x54
f32.lt0x5d
f64.lt0x63

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp