MOD Function (OpenOffice Calc)
The MOD function in OpenOffice Calc returns the remainder after division. Learn syntax, behavior with negative numbers, examples, and best practices.
Verification status: Consult the documentation, examples and any stated test scope below. How formula examples are checked
Availability and version history
- Introduced: Documented by Apache OpenOffice 4.1.16; original introduction not established.
- Availability: Supported in Apache OpenOffice 4.1.16, verified against its function registry. This identifies a supported release, not a final working version.
- Scope: Desktop Calc, using the English function name. Availability in other spreadsheet applications is separate.
- Checked: 2026-10-14 — function reference; versioned support. Documentation/source check; not a new native test. Existing example-specific test claims below retain their stated scope.
MOD returns the remainder associated with floor division. Its useful mathematical identity is number-divisor*INT(number/divisor). A nonzero remainder has the divisor’s sign, so negative operands need care when designing cycles or reconciling a quotient.
Syntax and arguments
=MOD(number; divisor)
Both arguments are required numeric expressions. divisor must be nonzero. Fractions are allowed; MOD is not limited to integers. Examples use Calc’s semicolon argument separator.
| Formula | Expected result |
|---|---|
=MOD(10;3) |
1 |
=MOD(-10;3) |
2 |
=MOD(10;-3) |
-2 |
=MOD(-10;-3) |
-1 |
=MOD(11.25;2.5) |
1.25 |
=MOD(12;3) |
0 |
For -10 and 3, the floor quotient is -4, and -10 = 3*(-4)+2. QUOTIENT(-10;3) uses truncation toward zero, so it cannot be substituted for INT(-10/3) in that identity.
Reproducible worksheet: rotating three assignments
Put labels Alpha, Beta and Gamma in E2:E4. Put sequence numbers 1, 2, 3, 4, 5 and 6 in A2:A7. In B2 enter =MOD(A2-1;3)+1 and fill down: the results are 1, 2, 3, 1, 2 and 3.
In C2 enter =INDEX($E$2:$E$4;B2) and fill down to obtain Alpha, Beta, Gamma, Alpha, Beta, Gamma. Keeping a sequence number in column A makes the assignment stable when you move the formula to another row. A formula based directly on ROW changes its phase when the starting row changes.
For a named one-column range List and numeric sequence variable n, the general form is =INDEX(List;MOD(n-1;ROWS(List))+1). Ensure the list is nonempty and the sequence numbers have the intended meaning.
Advanced applications and corrections
- Parity:
=MOD(A1;2)gives 0 or 1 for integer inputs, including negative integers with positive divisor 2. A fractional input is not an even/odd classification. - Fractional position:
=MOD(A1;1)gives 0.25 for 7.25 but 0.75 for -7.25. For a signed fractional part toward zero, use=A1-TRUNC(A1)instead. - Position within a ten-unit bucket:
=MOD(A1;10)is the offset, not the bucket number or its lower boundary. With A1=27 it gives 7;=INT(A1/10)*10gives the lower boundary 20. - Row cycles: starting in worksheet row 1,
=MOD(ROW()-1;3)+1cycles 1,2,3. If data start in row 2, use=MOD(ROW()-ROW($A$2);3)+1. - Pagination:
=MOD(ROW()-1;50)+1returns the position within a 50-row page when counting from row 1. Subtract the first data row instead if a header should be excluded. - Weekday offset:
=MOD(A1-DATE(1970;1;1);7)assigns 0 to Thursday, 1 to Friday and so on for date-only values. It is not an unexplained Sunday-based weekday number. Remove a datetime’s time portion first if required. - Label cycles:
=CHOOSE(MOD(ROW()-1;3)+1;"A";"B";"C")preserves the same row-1 phase.=MOD(ROW();2)can be used as an alternating-row conditional-formatting condition. - Other expressions:
=MOD(A1-B1;5)finds a difference’s remainder;=MOD(Sheet1.A1;12)reads another sheet.
Errors and numerical limits
A zero divisor is invalid. Validate the divisor before calculation instead of assuming a blank capacity or period represents a legitimate zero-length cycle. Exact displayed error codes can vary by the input path; no native error-code test is claimed here.
MOD does not ignore errors, text and logical values as if it were a statistical range function. Check numeric input deliberately, especially imported text and formulas that return an empty string. An error in A1 or B1 must be investigated upstream.
Decimal MOD calculations use finite-precision arithmetic. Tiny residuals can occur near a multiple; if the business rule has a fixed precision, apply that policy consistently rather than using an arbitrary equality tolerance. Very large values can have already lost low-order digits.
Documentation and verification
The OpenOffice MOD reference states the mathematical identity and supports fractional inputs. The 4.1.16 implementation uses an integer-divisor remainder branch and a separate approximate-arithmetic branch. The examples are independent arithmetic results, not a new native test. To reconstruct an ordinary numeric input use =B1*INT(A1/B1)+MOD(A1;B1) with B1 nonzero, allowing for floating-point precision.