Modulo (Negative Numbers)
Result
a mod b 2
Note Mathematical modulo: result is always ≥ 0
Calculate modulo for negative numbers (mathematical definition).
Formula
Math modulo: ((a % b) + b) % b — always non-negative
- Math modulo: ((a % b) + b) % b — always non-negative
Modulo (Negative Numbers)
Modulo (Negative Numbers) calculation.
Frequently asked questions
How is Modulo (Negative Numbers) calculated?
Math modulo: ((a % b) + b) % b — always non-negative