Skip to content

retain dollar sign when rounding to zero - #2997

Merged
h-a-n-a-s-h-i merged 2 commits into
storytold:mainfrom
Harrison-Booth:gc-build-g708x
Oct 31, 2026
Merged

h-a-n-a-s-h-i merged 2 commits into
storytold:mainfrom
Harrison-Booth:gc-build-g708x

Conversation

@Harrison-Booth

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

Copy link
Copy Markdown
Contributor

Summary

  • Preserve DOLLAR's negative layout when a negative amount rounds to zero at zero or positive decimal precision.
  • Keep exact zero unsigned, and match Excel's positive layout when negative decimal places round a negative amount to zero.
  • Add regressions for tiny negatives, signed zero, positive controls, negative decimal places, and values that round away from zero.
  • Record the measured behavior in function-parity.md.

Checked in a temporary unsaved workbook in Windows Excel 16.0 build 20527, LCID 1033. DOLLAR(-0.0001,0) returned ($0), DOLLAR(-0.0001,-1) returned $0, and FIXED(-0.0001,0) returned 0. Exact zero and negative zero returned $0. The workbook was closed without saving.

Validation

  • cargo fmt --check — passed.
  • git diff --check — passed.
  • Windows Excel COM behavior check — passed; no workbook was saved.
  • Clippy, crate tests, and desktop app build were not run locally under the GridCraft task restriction; fork CI should run the code checks.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Negative values formatted with DOLLAR now retain the negative currency layout when rounding to zero at nonnegative precision. Exact zero and negative zero remain unsigned, while negative precision retains the positive layout.
  • Documentation
    • Updated the function parity notes with the DOLLAR formatting behavior, its distinctions across precision settings, and related comparison details, including the corresponding FIXED result. The notes also include the review and update date.

@coderabbitai

coderabbitai Bot commented Oct 31, 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 11b54eb and 3174020.

Files selected for processing: 1
  • docs/function-parity.md
Files skipped from review as they are similar to previous changes: 1
  • docs/function-parity.md

Limit details: You’ve used all 10 included reviews currently available.

Walkthrough

DOLLAR retains a negative currency format when a negative input rounds to zero at nonnegative precision. Tests cover zero-sign and precision cases. The parity worksheet records the behavior and its measurement details.

Changes: DOLLAR formatting

Layer / File(s) Summary
Negative-zero formatting and parity coverage
crates/functions/src/text.rs, docs/function-parity.md
DOLLAR retains the negative format for negative inputs that round to zero at nonnegative precision. Tests cover zero, negative zero, positive values, and negative precision. The parity worksheet records this behavior and the contrasting FIXED result. The worksheet review and update dates are 2026-10-31.

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

Change: Bug fix

Suggested reviewers: echelon

Merge Risk: Minimal · up to 31740

The formatting change is ready to merge after the planned CI checks.

Architecture risk: Low · up to 11b54

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; 1 changed file maps 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/text.rs: dollar now formats a rounded zero as negative currency when precision is nonnegative and the original input is negative; negative zero and values rounded to zero at negative precision remain unsigned.
  • observed — Modified behavior in crates/functions/src/text.rs: Added DOLLAR expectations for negative values rounding to zero at nonnegative precision, zero and negative-zero inputs, positive values, and negative precision, plus a FIXED expectation confirming its zero-sign formatting.
  • observed — Modified behavior in docs/function-parity.md: The review and update dates change to 2026-10-31, and the change note documents DOLLAR’s negative-zero layouts by precision, including the Windows Excel measurement details.
  • observed — Modified behavior in docs/function-parity.md: A 2026-10-31 revision-history entry records DOLLAR’s behavior for negative amounts that round to zero, the unsigned treatment of exact and negative zero, and the contrasting FIXED result.
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 directly describes the main change: preserving the DOLLAR negative layout when a value rounds to zero. It is concise and specific, although it does not mention that the behavior applies to n…
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: Title check

Explanation

The title directly describes the main change: preserving the DOLLAR negative layout when a value rounds to zero. It is concise and specific, although it does not mention that the behavior applies to negative inputs.

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 1 functions across 1 files. (1 skipped: 1 unsupported.)

Resolution

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

Finishing Touches
🧪 Generate unit tests (beta)
  • 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.

@h-a-n-a-s-h-i
h-a-n-a-s-h-i merged commit 64ea0cb into storytold:main Oct 31, 2026
6 checks passed
@echelon

echelon commented Oct 31, 2026

Copy link
Copy Markdown
Member

Landed in main (fb1e59f). Thank you for the contribution, @Harrison-Booth! (#2996 also changed DOLLAR; the merged version keeps its 254-character limit and your sign rule.)

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.

3 participants