Modulo Calculator
Calculate a mod b and compare JavaScript-style remainder with Python-style modulo for positive, negative, integer, and decimal inputs.
Modulo and remainder intent
English SERPs mix two intents: a basic a mod b calculator for positive integers, and developer-style questions about negative numbers. This tool keeps both results visible so the difference is explicit.
For a truncated remainder, q is truncated toward zero. For Python-style modulo, q is floored.
- Use the main answer for JavaScript, C, and Java-style remainder behavior.
- Use the Python-style row when the modulo result should follow the divisor sign.
- For positive integers, both methods usually return the same value.
Negative number behavior
| Expression | Truncated remainder | Python-style modulo |
|---|---|---|
| 13 mod 5 | 3 | 3 |
| -13 mod 5 | -3 | 2 |
| 13 mod -5 | 3 | -2 |
Frequently Asked Questions
Sources and References
- Modulo CalculatorCalculatorSoup
- Remainder (%)MDN Web Docs
- Expressions - Binary arithmetic operationsPython Documentation
Calculations are based on the listed reference sources. Links open in a new tab.
Related Tools
Find the absolute value of a number or the distance between two numbers on a number line. Includes sign, opposite number, and decimal input support.
Round numbers to decimal places, whole numbers, or a nearest multiple. Compare half-away, half-even, ceiling, floor, and truncation results.
Calculate n! for non-negative integers from 0 to 170. See the exact factorial value, digit count, and multiplication steps.
Calculate percent of a number, what percent one number is of another, reverse percentage, percentage change, and add or subtract a percentage.