rem: Wasm numeric instruction
The rem numeric instructions, short for remainder, are used to calculate the remainder left over when one integer is divided by another integer, similar to the % operator in other languages. The rem instructions are only available for the integer types and not for the floating point types.
The **`rem`** [numeric instructions](/docs/WebAssembly/Reference/Numeric), short for _remainder_, are used to calculate the remainder left over when one integer is divided by another integer, similar to the **`%`** operator in other languages. The **`rem`** instructions are only available for the integer types and not for the floating point types.
tabbed-taller
```wat interactive-example
(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)
)
```
```js interactive-example
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)
```
| Instruction | Binary opcode |
| ----------- | ------------- |
| `i32.rem_s` | `0x6f` |
| `i32.rem_u` | `0x70` |
| `i64.rem_s` | `0x81` |
| `i64.rem_u` | `0x82` |
## Specifications
## Browser compatibility
Cite this
"rem: Wasm numeric instruction". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/WebAssembly/Reference/Numeric/rem