Modulo Calculator
This modulo calculator uses a floor quotient to find the modulo of two entered numbers. For 17 modulo 5, the quotient is three and the result is two because 17 = 5 × 3 + 2. Enter a nonzero divisor and review both the quotient and the modulo result.
Loading calculator. JavaScript is required.
Your result
For negative values, the convention matters. The modulo calculator returns three for -17 modulo 5 because the floor quotient is negative four: -17 = 5 × (-4) + 3. A truncating remainder calculation would give negative two instead. This page states its convention so the sign of the answer is not left to guesswork.
On this page
How to use the modulo calculator
Enter the number to be divided as dividend a and the divisor as b. Both may be signed whole numbers or supported finite decimals, but b cannot be zero. Use a decimal point without grouping commas. Calculate to see the integer floor quotient and the modulo value that remains after subtracting b times that quotient.
Check the order of your inputs. Seventeen modulo five is two, while five modulo seventeen is five. The modulo calculator does not treat its two fields as interchangeable. If the values describe measurements or a repeating period, keep compatible units and preserve the sign convention used by the surrounding problem.
The floor-quotient formula
This page defines q = floor(a/b) and r = a - bq. Floor means the greatest integer that is no larger than the exact quotient. For a positive quotient of 3.4, floor gives three. For a negative quotient of -3.4, floor gives negative four, not negative three.
With b positive, the result satisfies 0 ≤ r < b. With b negative, it satisfies b < r ≤ 0. A nonzero result therefore has the same sign as the divisor under this convention. The modulo calculator uses exact decimal ratios within its input limits to select q and compute r, avoiding a rounded decimal quotient as an intermediate decision.
Three worked modulo examples
Example one uses a = 17 and b = 5. The exact quotient is 3.4, so q = 3. Subtracting 5 × 3 from seventeen gives r = 2. The reconstruction check is 5 × 3 + 2 = 17, and the result lies between zero and five as required for a positive divisor.
Example two uses a = -17 and b = 5. The exact quotient is -3.4, whose floor is -4. The modulo result is -17 - 5 × (-4) = 3. The positive result is consistent with the positive divisor. Rounding the quotient toward zero would select -3 and answer a different remainder question.
Example three uses a = 0.3 and b = 0.2. Their exact entered decimal ratio is 1.5, so the floor quotient is one and the modulo result is 0.1. Scaling both inputs by ten gives the equivalent integer calculation 3 modulo 2 = 1, followed by scaling the remainder back by one tenth.
Modulo calculator checks for negative divisors
The modulo calculator also accepts a negative divisor. With a = 17 and b = -5, q = floor(-3.4) = -4. Then r = 17 - (-5 × -4) = -3. That result is greater than negative five and no greater than zero. Its sign follows the negative divisor.
When a is an exact integer multiple of b, the modulo result is zero regardless of their signs. A zero dividend also produces quotient zero and result zero for every permitted nonzero divisor. Check both reconstruction and the applicable result interval. Reconstruction alone is insufficient because many integer quotient and remainder pairs can satisfy a = bq + r.
Modulo calculator limits and decimal precision
The modulo calculator supports finite input magnitudes up to 1,000,000,000,000 and at most twelve effective decimal places after normalization. Trailing zeros do not add precision. Supported scientific notation has an exponent from negative twenty-four through positive twenty-four, provided the normalized number still meets the magnitude and decimal-place limits.
The entered decimal values are converted to scaled integers, and the calculation uses exact integer arithmetic before restoring the decimal scale. It does not infer unentered digits from a rounded measurement. A very small nonzero divisor can produce a large integer quotient, so keep the complete quotient when exporting or checking reconstruction rather than rounding it to fit a smaller display.
Use modulo for a repeating numerical cycle
For a positive period, modulo maps numerical offsets into one cycle. With period twelve, an offset of negative one maps to eleven, while an offset of thirteen maps to one. This is useful when reasoning about repeating index positions, provided you define the starting position and whether your indexing begins at zero. With zero-based positions, multiples of twelve map to position zero. A one-based label may need a separate mapping after this calculation.
The modulo calculator performs one numeric floor-division calculation. It does not calculate modular powers, solve a system of congruences or infer calendar and timezone rules from a cycle length. Some software uses the percent symbol for a truncating remainder instead. Check the relevant language's definition before assuming its operator matches this calculator for negative inputs.
Questions about modulo calculator
Which modulo convention does this calculator use?
It uses q = floor(a/b), followed by r = a - bq. A nonzero result has the divisor's sign. For positive b, the result is at least zero and smaller than b. For negative b, it is greater than b and at most zero. Other uses of the word modulo may state a different convention, so compare definitions.
Why is -17 modulo 5 equal to three here?
The exact quotient is negative 3.4, and floor selects negative four. Subtracting five times negative four from negative seventeen gives three. A quotient truncated toward zero would be negative three and would leave negative two. Both pairs reconstruct the dividend, but they follow different rules for selecting the quotient and the sign of the remainder.
Can the modulo calculator accept a negative divisor?
Yes. Under the stated floor convention, a nonzero modulo result then has a negative sign. For seventeen modulo negative five, the floor quotient is negative four and the result is negative three. The reconstruction is (-5) × (-4) + (-3) = 17. Keep the negative sign in the divisor when comparing this with another implementation.
Is modulo the same as a remainder operator in programming?
It depends on how that operator is defined. JavaScript's percent operator uses a truncating remainder, while some languages use floor-based modulo for that symbol. They agree in many positive-input cases and can differ when the signs differ. This tool states floor division explicitly. Check the language documentation instead of relying on the symbol alone.
Are decimal inputs handled as binary floating-point remainders?
The calculator treats supported finite decimal inputs as exact decimal ratios. It scales them to integer values before computing the quotient and modulo, then restores the scale. Thus 0.3 modulo 0.2 is 0.1 in this input model. This can differ from the last digits produced by a direct binary floating-point remainder operation in another program.
What happens when the divisor is zero?
The calculation is rejected. Division by zero does not supply the integer quotient needed for this modulo definition. This remains invalid when the dividend is also zero. Enter a nonzero divisor rather than treating zero as a repeating cycle length or interpreting an error as a valid modulo result of zero.
Why do I need to check the result interval?
The equation a = bq + r alone does not identify one quotient and remainder pair. The floor rule also constrains r relative to b. With positive five, r must be from zero inclusive to five exclusive. This interval check distinguishes the intended modulo answer from another pair of numbers that reconstructs the dividend.
Can the result be zero for negative values?
Yes. If the dividend is an exact integer multiple of the nonzero divisor, the modulo result is zero. For example, negative fifteen modulo five is zero because -15 = 5 × (-3). The input signs do not require a nonzero answer. The display uses ordinary zero rather than a signed negative-zero notation.
What does the precision limit permit?
Each input may have magnitude at most one trillion and no more than twelve effective decimal places after normalization. Supported exponent notation is bounded separately. Trailing fractional zeros are removed before checking the decimal-place count. The stated limits describe this exact decimal model and do not promise arbitrary-length decimal or symbolic input.
Does a twelve-step cycle calculate a clock time?
It calculates a numerical position within a period of twelve. To interpret that position as a time, you must also define the starting point, counting convention and any relevant date or timezone rules. Modulo arithmetic alone does not determine daylight-saving transitions or calendar boundaries. Use it only for the part of the model that is a stated repeating numerical cycle.
What should I preserve with an exported result?
Keep dividend a, divisor b, the floor-quotient convention and the complete integer quotient as well as the modulo value. Preserve the exact decimal input text when its precision matters. A CSV result is the current output rather than a record of every attempt, so retain the corresponding inputs separately for someone who needs to reproduce the calculation.
Sources and method notes
Method and source notes checked on 26 November 2026. The diagrams are original explanatory drawings. Read the privacy policy for other site services.