Modulo Calculator
Find the remainder and quotient when dividing two numbers.
Result
How it is calculated
The quotient is the floored division q = floor(a / b), and the remainder is r = a − q × b, where a is the dividend and b the divisor. Because the quotient is rounded down (toward negative infinity), not toward zero, the remainder always takes the sign of the divisor: it is between 0 and b for a positive divisor, and between b and 0 for a negative one.
Decimals are accepted and handled exactly, so 17.5 mod 5 gives quotient 3 and remainder 2.50, and 0.3 mod 0.1 gives quotient 3 and remainder 0.00. The quotient is shown as a whole number and the remainder with two decimals. A divisor of 0 gives no result.
Worked example
Let a = -17 and b = 5. a / b = -3.4, and floor(-3.4) = -4, so the quotient is -4. The remainder is r = -17 − (-4 × 5) = -17 + 20 = 3.00. Check: -4 × 5 + 3 = -17. A truncating calculator would give -3 and -2 instead, but here the remainder stays non-negative for a positive divisor.
Common mistakes
- Expecting −17 mod 5 to be −2, as in C, Java or JavaScript's % operator: this tool floors the quotient, so the answer is 3 (Python-style modulo).
- Reading the quotient of a negative division as truncated: −17 ÷ 5 is shown as −4, not −3.
- Entering a decimal dividend and assuming it is rounded first: the decimal part stays in the remainder (17.5 mod 5 = 2.50).
- Using it for a clock or array wrap with a negative offset and subtracting the divisor by hand: with a positive divisor the result is already in the 0 to b range.
About this calculator
This tool computes the quotient and remainder when one number is divided by another — the modulo operation (a mod b) returns just the remainder, the amount left over after dividing a by b as many whole times as possible. For example, 17 mod 5 is 2, because 5 fits into 17 three whole times with 2 left over.
It is used by programmers implementing logic like wrapping a value around a fixed range (clock arithmetic, array indexing, cycling through a list), checking whether one number evenly divides another (a mod b = 0), or distributing items evenly into groups with a leftover. Students also use it to check long-division-style remainder problems in arithmetic and number theory coursework.
Was this helpful?
You can pick up to 3 reactions.
Popular calculators
Loan Calculator
Monthly payment, total interest and full amortization schedule.
Percentage Calculator
Percent change, percent of, and ratio calculations.
Discount Calculator
Calculate final price, savings, and discount amount.
BMI Calculator
Body mass index from height and weight (metric or imperial).
Age Calculator
Compute your exact age in years, months and days from a birth date.
Compound Interest Calculator
Calculate the final amount and interest earned with compounding.
All Calculators
- Loan Calculator
- Profit Calculator
- Discount Calculator
- BMI Calculator
- Percentage Calculator
- Ideal Weight Calculator
- Age Calculator
- Pregnancy Due Date Calculator
- Compound Interest Calculator
- BMR Calculator (Basal Metabolic Rate)
- Tip Calculator
- Fuel Cost Calculator
- Date Difference Calculator
- Sleep Cycle Calculator
- Daily Water Intake Calculator
- Simple Interest Calculator
- Heart Rate Zones Calculator
- Running Pace Calculator
- Pet Age Calculator
- Calories Burned Calculator
- Macro Calculator
- TDEE Calculator (Total Daily Energy Expenditure)
- Waist-to-Hip Ratio Calculator
- Honor Roll Calculator
- One Rep Max (1RM) Calculator
- Ovulation Calculator
- Electricity Cost Calculator
- Unit Price Calculator
- Savings Goal Calculator
- Break-Even Point Calculator
- Paint Calculator
- Course Grade Average Calculator
- Business Days Calculator
- Time Duration Calculator
- Fuel Economy Calculator
- Temperature Converter
- Tile Calculator
- Aspect Ratio Calculator
- Roman Numeral Converter
- Goal Weight Timeline Calculator
- Salary Converter (Hourly to Annual)
- Credit Card Validator (Luhn)
- Body Surface Area (BSA) Calculator
- Feels-Like Temperature Calculator
- Ohm’s Law Calculator
- PPI (Pixel Density) Calculator
- Molar Mass Calculator
- Zodiac Sign Calculator (Western + Chinese)
- IBAN Validator
- Shoe Size Converter
- Country Info & Dialing Code Lookup
- Time Zone Difference (World Clock)
- CAGR (Compound Annual Growth Rate) Calculator
- Rule of 72 Calculator
- Blood Alcohol Content (BAC) Calculator
- Lean Body Mass (LBM) Calculator
- Pythagorean Theorem Calculator
- Speed Converter
- Download Time Calculator
- Date Calculator (Add/Subtract)
No calculators found
Comments (1)
The sign of the remainder is where programming languages disagree. This tool floors the quotient, so negative 17 mod 5 gives 3, the way Python does it. JavaScript, C and Java return negative 2 for the same pair, because they truncate toward zero. If you are porting an index wraparound or a clock calculation, check which rule your language uses. Which language or problem are you checking against?