Skip to content

MOD: match Excel large quotient limit - #98

Open
Harrison-Booth wants to merge 1 commit into
mainfrom
gc-fix-2657
Open

Harrison-Booth wants to merge 1 commit into
mainfrom
gc-fix-2657

Conversation

@Harrison-Booth

@Harrison-Booth Harrison-Booth commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

Makes MOD return #NUM! when ABS(number/divisor) >= 1.1259E12, matching Excel 16.0, and adds the function's docs/function-parity.md row. The boundary and large quotient values are covered by regression cases.

Verification: Expected results come from the Excel 16.0 COM observations documented in the original combined PR. cargo fmt --check passed locally. Per task instructions, Rust tests were not run locally; fork CI runs them.

Summary by CodeRabbit

  • Bug Fixes

    • The MOD function now returns #NUM! when the absolute quotient of the number divided by the divisor is at least 1.1259E12. Division by zero continues to return an error.
    • Remainders continue to be calculated for quotients below the limit, including large quotients.
  • Documentation

    • Updated the function parity reference to document the MOD quotient limit.

@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 11bb673 and 5c31d7a.

Files selected for processing: 3
  • crates/functions/src/math.rs
  • crates/functions/src/math/tests.rs
  • docs/function-parity.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

Walkthrough

modulo now returns #NUM! when the absolute quotient reaches 1.1259e12. Regression tests cover cases above and below the threshold. The function parity document records the behavior for Excel 16.0.

Changes: MOD quotient limit

Layer / File(s) Summary
MOD threshold behavior
crates/functions/src/math.rs, crates/functions/src/math/tests.rs, docs/function-parity.md
modulo returns #NUM! when the absolute quotient is at least 1.1259e12. Tests cover quotients at and above the limit, as well as results below it. The parity document records the Excel 16.0 behavior and its revision date.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: aiongg, echelon

Merge Risk: Minimal · up to 5c31d

The focused MOD parity change is ready to merge, subject to normal CI checks.

Architecture risk: Low · up to 5c31d

The change affects 2 systems.

Changed systems: crates, docs

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — crates (service) was modified; 2 changed files map to changed impact.
  • observed — docs (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in crates/functions/src/math.rs: modulo adds a quotient-magnitude limit: when |x / d| >= 1.1259e12, it returns CellError::Num.
  • observed — Modified behavior in crates/functions/src/math/tests.rs: The mod_tiny_divisor_stays_in_range test, which asserted valid remainder properties for four tiny-divisor cases, was replaced by mod_quotient_limit. The replacement expects #NUM! for eight cases where the absolute quotient is at least 1.1259E12, and checks two MOD results below that limit.
  • observed — Modified behavior in docs/function-parity.md: The last-reviewed and last-updated dates change from 2026-10-15 and 2026-10-25 to 2026-10-30.
  • observed — Modified behavior in docs/function-parity.md: A Formula language row documents that Excel 16.0 MOD returns #NUM! when the absolute quotient is at least 1.1259E12; lower quotients return the remainder.
Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: updating MOD to match Excel’s large quotient limit.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 2 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant