Contact

MOD Function (Gnumeric)

Math Beginner Gnumeric

Calculate Gnumeric remainders with MOD, understand the divisor-sign convention and distinguish negative-input cases.

Verification status: See the evidence and test scope described in this guide. How formula examples are checked

MOD returns a division remainder using the divisor’s sign convention. It is useful for repeating cycles, grouping positions, and wraparound arithmetic. Negative inputs need special care because this convention may differ from a programming language’s remainder operator.

Syntax and contract

MOD(x, n)

x is the dividend and n is the nonzero divisor. For nonzero results, the remainder has the sign of n. With a positive divisor, the result is at least zero and less than that divisor; exact multiples return zero.

Original worked examples

=MOD(17,5)

The result is 2: 17 is three groups of 5 with 2 left over.

=MOD(19,5)

The result is 4: 19 is three groups of 5 with 4 left over. These examples require no worksheet inputs and were retained from the earlier guide.

Worked example: all four sign combinations

Formula Native result
=MOD(17,5) 2
=MOD(-17,5) 3
=MOD(17,-5) -3
=MOD(-17,-5) -2
=MOD(10,5) 0

A useful mathematical description is x - n*INT(x/n), where INT rounds down toward negative infinity. For -17 and 5, the whole-number quotient in that description is -4, so the remainder is -17 minus -20, or 3. This explains why simply attaching the dividend’s sign to a positive remainder gives the wrong answer.

For a worksheet, place dividends in A2:A5 and divisors in B2:B5, then fill =MOD(A2,B2) down column C. Keep the divisor visible because its sign determines the remainder convention.

Advanced use: a one-based repeating position

To map an integer position into a five-position cycle numbered 1 through 5, use =MOD(position-1,5)+1. At position 6, =MOD(6-1,5)+1 returns 1. Subtracting one before the remainder and adding one afterward shifts the natural zero-based remainder into one-based numbering.

Document whether negative or zero positions are allowed in your application. The formula can wrap them mathematically, but that does not establish that they are valid business inputs. For fractional measurements, floating-point representation can leave a tiny residual near an expected boundary; choose a numerical tolerance or final rounding policy appropriate to the data.

Errors and troubleshooting

=MOD(1,0) returns #DIV/0!. Check the actual divisor cell and any calculation that produces it before hiding this error. A negative divisor is valid and intentionally produces a negative nonzero remainder.

If results disagree with another application or code implementation, first compare the convention for negative operands. Do not treat positive-only examples as sufficient compatibility testing. Also distinguish the remainder from the quotient: MOD tells you what is left, not how many whole groups fit.

Availability and version history

  • Introduced: Documented by Gnumeric 0.27, whose release notes mention fixes; the original introduction is not established.
  • Historical source evidence: Supported in Gnumeric 1.12.62, based on the function-specific registration.
  • Scope: Desktop; the fn-math function module must be included and enabled.
  • Historical check: October 14, 2026. The retained 1.12.62 registration check is not a native execution claim for that release.

New verification: Official Gnumeric 1.12.57 source and bounded native engine cases were checked on 17 October 2026 under C.UTF-8. This guide’s worked results refer to that release; the historical 1.12.62 registration is retained separately and does not establish identical behavior. The selected example below is GUI-verified; a last-working release is not established.

Documentation and verification

Native application screenshot

The selected cell C2 contains =MOD(A2,B2) and displays 2. The screenshot preserves the example input positions described above. Only this selected example is GUI-verified; the other checks retain their stated engine-test scope.

Gnumeric MOD selected formula and native result

Actual Gnumeric 1.12.57 application, captured 17 October 2026. GUI locale was not independently recorded.