Calculators King

Probability

Modulo Calculator

Divide a dividend by a divisor and show both the JavaScript truncated remainder and the floor remainder, plus the quotients.

Worksheet

Press Calculate to see the result.

Divide a dividend by a divisor and show both the JavaScript truncated remainder and the floor remainder, plus the quotients.

What this calculator answers

Remainder arithmetic looks settled until the dividend turns negative. JavaScript's % operator truncates the quotient toward zero and gives the remainder the sign of the dividend, so a negative dividend can produce a negative remainder. Floor modulo instead uses a quotient rounded toward negative infinity, and when the divisor is positive that remainder is 0 or positive. This page shows both remainders and both quotients for the same pair of numbers. It is ordinary division arithmetic. It is not a probability model, a standard error, or a sampling distribution, and a divisor of 0 is rejected because division by zero is undefined.

The truncated quotient is the division rounded toward zero, and the truncated remainder is the JavaScript % result. The floor quotient is the division rounded toward negative infinity, and the floor remainder is the dividend minus that quotient times the divisor. The headline is the floor remainder. Supporting counts and intermediate terms sit under the headline so a reader can see what was divided by what. When a checkbox or a tail setting changes the divisor or the rejection region, that choice appears in the steps rather than vanishing into a silent default.

The formula, written out

Truncated remainder and floor modulo uses this relationship.

Truncated: q = trunc(a / b), r = a % b. Floor: q = floor(a / b), r = a − q × b.

  • a. The dividend.
  • b. The divisor, which cannot be 0.
  • trunc. Round toward zero, which is JavaScript's % companion.
  • floor. Round toward negative infinity, which keeps a non-negative remainder when b is positive.

Division writes the dividend as quotient times divisor plus remainder. Choosing the quotient by truncating toward zero forces the remainder to carry the sign of the dividend in JavaScript. Choosing the quotient by flooring forces the remainder to satisfy a different identity, and that remainder is at least 0 whenever the divisor is positive. Both identities are checked in the steps with the numbers you typed. The algebra is the named textbook identity for this worksheet. Intermediate products and quotients appear in order so a calculator and a pencil can agree to the displayed rounding. If a neighbouring page uses a different divisor or a continuity correction, that page says so on its own ticket.

A full worked example

Example loaded in the worksheet

The form is prefilled with a small example so every arithmetic step can be checked by hand. Change one field after you finish the walkthrough and confirm the ticket moves the way the formula predicts.

The dividend is 17 and the divisor is 5. A divisor of 0 would have been rejected. JavaScript's % operator truncates the quotient toward 0, and the remainder takes the sign of the dividend. The truncated quotient is 3, and the truncated remainder is 2, the same result as the % operator.

Check the truncated identity: 5 × 3 + 2 = 17. The floor quotient rounds toward negative infinity and equals 3. The floor remainder is 17 − 3 × 5 = 2.

On this pair the two remainders match at 2. They split when the dividend is negative and the divisor is positive. The divisor is positive, so the floor remainder 2 is 0 or greater. This page is division arithmetic, not a statistics tool.

Figures from the worked example
Floor remainder2
Truncated remainder (JavaScript %)2
Floor quotient3
Truncated quotient3

A second situation

A negative dividend, where the two remainders split

The dividend is −17 and the divisor is 5. A divisor of 0 would have been rejected. JavaScript's % operator truncates the quotient toward 0, and the remainder takes the sign of the dividend. The truncated quotient is −3, and the truncated remainder is −2, the same result as the % operator.

Check the truncated identity: 5 × −3 + −2 = −17. The floor quotient rounds toward negative infinity and equals −4. The floor remainder is −17 − −4 × 5 = 3.

On this pair the remainders differ: truncated −2 and floor 3. The divisor is positive, so the floor remainder 3 is 0 or greater. This page is division arithmetic, not a statistics tool.

Figures from the worked example
Floor remainder3
Truncated remainder (JavaScript %)−2
Floor quotient−4
Truncated quotient−3

A dividend of 17 and a divisor of 5 produce the same remainder either way, because the quotient is already an integer neighborhood with a positive dividend. A dividend of −17 makes trunc(−17/5) equal −3 and floor(−17/5) equal −4, so one remainder is negative and the other is positive. The split is the reason both numbers are on the ticket. The second example changes the feature that this formula is sensitive to, and the ticket shows the new figure beside the same definition. That contrast is the fastest way to see which input owns the movement.

What moves when the input moves

The dividend moved from 17 to 18. The headline result went from 2 to 3.

The nudged inputs

The dividend is 18 and the divisor is 5. A divisor of 0 would have been rejected. JavaScript's % operator truncates the quotient toward 0, and the remainder takes the sign of the dividend. The truncated quotient is 3, and the truncated remainder is 3, the same result as the % operator.

Check the truncated identity: 5 × 3 + 3 = 18. The floor quotient rounds toward negative infinity and equals 3. The floor remainder is 18 − 3 × 5 = 3.

On this pair the two remainders match at 3. They split when the dividend is negative and the divisor is positive. The divisor is positive, so the floor remainder 3 is 0 or greater. This page is division arithmetic, not a statistics tool.

Figures from the worked example
Floor remainder3
Truncated remainder (JavaScript %)3
Floor quotient3
Truncated quotient3

How to read the result

Read the floor remainder as the non-negative residue when the divisor is positive. Read the truncated remainder as what the JavaScript % operator returns, which can be negative. The two quotients explain the gap. Neither result is a probability. Say the unit, the sample size or contract terms, and the formula name in the same sentence as the figure. A number without those three pieces invites a later reader to invent a definition that this page never used.

Write the result with its unit, the inputs that produced it, and the name of the formula. Write the result with its unit, the inputs that produced it, and the name of the formula. If the ticket shows a decision sentence, quote the alpha and the tail with it. If the ticket shows a money or dose figure, quote the rate and the schedule that produced it.

Assumptions that have to stay true

  • The divisor is not 0.
  • Both values are finite numbers.
  • The truncated remainder is defined to match JavaScript's % operator.
  • The floor remainder is non-negative only when the divisor is positive. A negative divisor can leave a negative floor remainder.

If an assumption above is false, do not average the discomfort away. Change the worksheet or change the question. A correct arithmetic step on the wrong model is still the wrong answer for the decision you are trying to make.

Mistakes that change the answer

  • Assuming a % b is always at least 0. In JavaScript the sign follows the dividend.
  • Using the truncated remainder as a clock position when the dividend is negative. The clock wants the floor remainder.
  • Dividing by 0 and expecting either remainder to exist.
  • Confusing this arithmetic with a statistical modulus, a circular distribution, or a standard error. This page only divides.

Where a different calculator is the honest choice

Use the factorial or combination calculators when the question is a count of arrangements rather than a remainder. Use the probability calculator when the question is a complement, a union, or at least one success. Nothing on this page estimates a mean or an interval. Related links under the essay open pages that keep their own formulas instead of hiding a mode switch inside this ticket.

When the job changes, move to a page built for that job: Factorial Calculator, Combination Calculator, Probability Calculator.

Check yourself

What are the truncated remainder and the floor remainder of 17 divided by 5?

Both quotients are 3 and both remainders are 2, because 5 × 3 + 2 = 17. They split when the dividend is negative.

Using the result in a sentence

Clock positions, hash buckets, checking a JavaScript remainder before using it as an array index, and seeing why a negative dividend surprises people are the uses. Keep the count, the unit, and the assumption list beside any copy of the number that leaves this browser tab.

Floating-point division of values that are not integers can leave a remainder that is a hair off the textbook fraction. Very large magnitudes can also lose integer precision. The sign rules themselves are exact only in the arithmetic the machine actually performed. Pair the headline with the steps before you staff a route, set a grade boundary, or compare two contracts from a single number.

Questions people ask next

01What definition does the Modulo Calculator commit to?

This page uses Truncated remainder and floor modulo: Truncated: q = trunc(a / b), r = a % b. Floor: q = floor(a / b), r = a − q × b.. Division writes the dividend as quotient times divisor plus remainder. Choosing the quotient by truncating toward zero forces the remainder to carry the sign of the dividend in JavaScript. Choosing the quotient by flooring forces the remainder to satisfy a different identity, and that remainder is at least 0 whenever the divisor is positive. Both identities are checked in the steps with the numbers you typed. If a textbook uses a different divisor, a different continuity correction, or a different rounding rule, the last digits can move, so the definition is printed above the result. The worksheet asks for Dividend a, Divisor b, and it refuses a blank that the formula cannot interpret. Keep that printed definition in the sentence you write next to the figure so a later reader can rebuild the arithmetic without guessing which convention you chose.

02How should the worked example be read out loud?

In the loaded example the floor remainder is 2. Read the floor remainder as the non-negative residue when the divisor is positive. Read the truncated remainder as what the JavaScript % operator returns, which can be negative. The two quotients explain the gap. Neither result is a probability. Say the unit and the count before you say whether the number is large or small. Read the steps in order rather than jumping to the headline, because the intermediate terms are where a swapped percent and proportion usually hide. If the ticket shows both a primary figure and a comparison figure, name which one you are quoting.

03What is the fastest way to get a misleading result?

Assuming a % b is always at least 0. In JavaScript the sign follows the dividend. Floating-point division of values that are not integers can leave a remainder that is a hair off the textbook fraction. Very large magnitudes can also lose integer precision. The sign rules themselves are exact only in the arithmetic the machine actually performed. A second common failure is leaving a checkbox or tail setting in the wrong state and then treating the number as if the default had matched your plan. Reset the example, change one input, and confirm the ticket moves in the direction the formula predicts before you trust a live run.

04When should I leave this page for a different calculator?

Use the factorial or combination calculators when the question is a count of arrangements rather than a remainder. Use the probability calculator when the question is a complement, a union, or at least one success. Nothing on this page estimates a mean or an interval. The related links under the essay go to those worksheets, which keep their own formulas instead of hiding them in a mode switch. If the question changed from a summary to a test, from a payment to a refinance, or from a raw score to a percentile, switch pages rather than forcing this ticket to answer a job it was not built for.

05What belongs in the sentence next to the number?

Both quotients are 3 and both remainders are 2, because 5 × 3 + 2 = 17. They split when the dividend is negative. Name the formula, the sample size or the inputs, and the unit before you compare the figure with someone else's. A bare number without those three pieces cannot be audited when a score, a rate, or a lab value is challenged later. Store the inputs beside the result whenever the figure will travel into a report.