Opcodes · arithmetic · enabled

OP_MOD (0x97)

Pushes the remainder of a divided by b. Modulo by zero fails. Re-enabled on BCH in May 2018. Since May 2025 numbers may be up to 10,000 bytes long (BigInt).

Verified
Stack in → out
a b → a%b
Cost
Base instruction cost 100, plus twice the result length, plus the product of the two input lengths to cover O(n²) work (2025 VM limits).
Bitcoin status
Disabled in Bitcoin (BTC)Disabled since 2010; an OP_SUCCESS code in Tapscript.

Example

OP_7 OP_2 OP_MOD OP_1 OP_EQUAL

Step through it opcode by opcode in Bitauth IDE, the in-browser BCH VM debugger.

Sources

  1. BCHN upgrade specs: Restore disabled script opcodes, May 2018
  2. CHIP-2021-05 VM Limits: Targeted Virtual Machine Limits
  3. CHIP-2024-07 BigInt: High-Precision Arithmetic