Skip to content

Use an unscaled formatter for a zero SI-prefix reference - #159

Open
xiehuanyi wants to merge 1 commit into
d3:mainfrom
xiehuanyi:fix/zero-prefix-reference
Open

xiehuanyi wants to merge 1 commit into
d3:mainfrom
xiehuanyi:fix/zero-prefix-reference

Conversation

@xiehuanyi

Copy link
Copy Markdown

formatPrefix(".1", 0) returns a formatter that produces NaN for every input, including zero and ordinary finite numbers. The exponent of a zero reference is undefined, so it propagates into the scale factor.

Use exponent zero for a zero reference (including negative zero), which selects no SI prefix and retains the ordinary fixed-precision formatter. The regression covers zero, positive and negative inputs and a negative-zero reference. Existing nonzero-prefix behavior remains covered by the suite.

Validation: the new regression fails on unchanged main (NaN instead of 0.0); npm test -- --run passes all 169 tests, npm run lint and git diff --check pass on Node 22.23.1. Browser execution and the Node 12 minimum were not exercised.

AI disclosure: OpenAI Codex assisted with investigation, implementation, regression tests, and this description.

AI-assisted implementation and verification using OpenAI Codex.
Copilot AI balanced review requested due to automatic review settings October 10, 2026 17:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants