Skip to content

fix: normalize negative zero at integer precision - #16

Open
nrps9909 wants to merge 1 commit into
react-component:masterfrom
nrps9909:codex/fix-negative-zero-precision-2
Open

fix: normalize negative zero at integer precision#16
nrps9909 wants to merge 1 commit into
react-component:masterfrom
nrps9909:codex/fix-negative-zero-precision-2

Conversation

@nrps9909

Copy link
Copy Markdown

Summary

  • normalize negative fractional values that round or truncate to zero at integer precision
  • preserve the existing half-away-from-zero boundary while avoiding a displayed -0
  • add regression coverage for rounded and cut-only paths

Fixes #2

Why

At precision 0, toFixed currently combines the negative sign with the zero integer before returning, so a value such as -0.4 is formatted as -0. The existing decimal contract already normalizes an exact negative zero to 0.

This utility is also consumed directly by react-component/input-number: its non-typing display formatter and value-alignment paths both call toFixed.

Regression proof

  • Base f0b75c33c6069938789462e61864b7f2f4af6551: the focused regression failed with Expected: "0" and Received: "-0" for toFixed('-0.4', '.', 0).
  • This head: -0.4 rounds to 0, -0.5 still rounds to -1, and cut-only -0.9 returns 0.

Testing

  • npm test -- tests/util.test.tsx --runInBand — 25/25 passed
  • npm test -- --runInBand — 46/46 passed
  • npm run tsc
  • npm run lint
  • npm run compile
  • Prettier check and git diff --check

AI assistance

Codex was used to trace the react-component/input-number consumer call sites, audit all open pull-request files for overlap, draft the minimal change and regression tests, and run the verification commands. I reviewed the source, diff, test output, and final commit before submission.

@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f149d958-c3fc-4e54-8d22-0702c8121dc8


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.

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

Labels

None yet

1 participant