i32.div_s
Pops two i32 values off the stack, divides the first by the second, disgarding any remaining amount, and then pushes the result back on to the stack. This looks at the values as signed integers (can be negative).
$result = $first / $second

Syntax

i32.div_s

Stack In

i32 The first value to be divided.
i32 The second value to divide by.

Stack Out

i32 The result of dividing the first value by the second one.

Examples

;; Push the i32 values onto the stack
i32.const 12
i32.const 3
  
;; Divide 12 by 3 seeing it as signed
i32.div_s

;; The stack contains an i32 value of 4 (result = 12 / 3)
;; Push the i32 values onto the stack
i32.const 0xF178CD56
i32.const 2
  
;; Divide 0xF178CD56 by 2 seeing it as signed
i32.div_s

;; The stack contains an i32 value of -121870677 (result = -243741354 / 2)
;; Push the i32 values onto the stack
i32.const 0xF178CD56
i32.const 2

;; Divide 0xF178CD56 by 2 seeing it as unsigned
i32.div_u

;; The stack contains an i32 value of 2025612971 (result = 4051225942 / 2)