Skip to content

Correctly format negative single digit cent amounts. - #782

Open
polskus wants to merge 1 commit into
oss-apps:mainfrom
polskus:fix/negative-single-cent-display
Open

polskus wants to merge 1 commit into
oss-apps:mainfrom
polskus:fix/negative-single-cent-display

Conversation

@polskus

@polskus polskus commented Oct 24, 2026 •

Copy link
Copy Markdown

Description

Negative cent amounts from -1 to -9 were incorrectly formatted to be 0.1 and 0.9 respectively. The issue was the negative sign '-' which caused the padding to be off by one.

A test including a negative number was also added.

This completes the fix in #591.

Checklist

  • I have read CONTRIBUTING.md in its entirety
  • I have performed a self-review of my own code
  • I have added unit tests to cover my changes
  • The last commit successfully passed pre-commit checks
  • Any AI code was thoroughly reviewed by me

Summary by CodeRabbit

  • Bug Fixes
    • Corrected currency formatting for negative bigint values with single-digit cents, so -7n displays as $0.07.
    • Negative currency values retain a leading minus sign when signed formatting is enabled.

Negative cent amounts from -1 to -9 were incorrectly formatted to be 0.1 and 0.9. The issue was the negative sign '-' which caused the padding to be off by one.
A test including a negative number was also added.
This completes the fix in oss-apps#591.
@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8080254a-cc92-4978-b917-7f2ef3a869ef
Commits

Reviewing files that changed from the base of the PR and between 3583568 and 8ee4baf.

Files selected for processing: 2
  • src/tests/number.test.ts
  • src/utils/numbers.ts

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

Walkthrough

The bigint currency formatter now calculates integer and fractional components from the absolute value. The test checks that both 7n and -7n format as '$0.07'.

Changes: Bigint currency formatting

Layer / File(s) Summary
Format bigint currency amounts
src/utils/numbers.ts, src/tests/number.test.ts
parseToCleanString uses the absolute bigint value for its integer and fractional components. The test covers positive and negative single-digit cents, both expecting '$0.07'.

Priority: Normal

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix

Suggested reviewers: friesischscott

Merge Risk: Minimal · up to 8ee4b

The negative single-digit cent formatting issue is corrected without an identified merge-blocking risk.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: correcting formatting for negative single-digit cent amounts.
Description check Passed The description explains the formatting defect, identifies the cause, notes the added test, and completes all checklist items. The optional demo section is omitted, but this does not prevent approval.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
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

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

This branch has not been deployed

No deployments
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