fix: align long ToMetric decimals with int behavior (#1699)#1795
fix: align long ToMetric decimals with int behavior (#1699)#1795wyf027 wants to merge 2 commits into
Conversation
For values below the first metric prefix, delegate to the double path when decimals are specified instead of padding fixed decimal places. Co-authored-by: Cursor <cursoragent@cursor.com>
📝 WalkthroughWalkthroughBuildRepresentation(long, ...) now delegates to the double ToMetric path when decimals > 0; tests were updated and new tests added to assert parity with int behavior and to adjust expected formatting outputs. ChangesAlign long.ToMetric decimals handling with int behavior
🎯 2 (Simple) | ⏱️ ~8 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the 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. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b53386267e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (decimals > 0) | ||
| { | ||
| return ((double)input).ToMetric(formats, decimals); | ||
| } |
There was a problem hiding this comment.
Preserve decimal padding for non-prefixed long metrics
Routing long values with decimals > 0 through the double overload drops trailing zeroes for values below 1000, because the double path rounds and then formats with default ToString semantics. That changes outputs like 123L.ToMetric(decimals: 1) from "123.0" to "123" (same for 0), which regresses existing long-format expectations and will break consumers that rely on fixed decimal precision in this range.
Useful? React with 👍 / 👎.
Update sub-prefix long cases and coverage assertions to match the double rounding path used by int.ToMetric, including decimals > 15. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Pushed test fixes for Azure CI (
These align with issue #1699 semantics. Re-running CI. |
|
Azure CI is green after test expectation updates ( |
|
Closing in favor of #1700 per @logiclrd's review on #1699. #1700 covers the full Sorry for the duplicate — should have coordinated with the existing PR. |
|
Superseded by #1700. |
Summary
longvalues below the first metric prefix, use the doubleToMetricpath whendecimalsis specified.((long)1).ToMetric(decimals: 5)returning"1.00000"instead of"1"likeint.Fixes #1699
Test plan
LongToMetricDecimalsMatchIntBehaviorfor values 1, 42, 999TestAllSymbolsAsLongcases unchanged for prefixed valuesmain