Skip to content

Latest commit

 

History

History
39 lines (26 loc) · 1.12 KB

07.mdx

File metadata and controls

39 lines (26 loc) · 1.12 KB
fork group
Frontier
Stop and Arithmetic Operations

Index 1 is top of the stack. See PUSH.

Notes

All values are treated as two’s complement signed 256-bit integers. Note the overflow semantic when −2255 is negated.

Stack input

  1. a: integer numerator.
  2. b: integer denominator.

Stack output

  1. a % b: integer result of the signed integer modulo. If the denominator is 0, the result will be 0.

Examples

* Input Output
1 10 1
2 3
* Input Output
1 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE
2 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD

Reproduce in playground.

Error cases

The state changes done by the current context are reverted in those cases:

  • Not enough gas.
  • Not enough values on the stack.