Skip to content

progress: promote unit on rounding and handle negative values in FormatNumber - #443

Open
TheNetherWatcher wants to merge 1 commit into
jedib0t:mainfrom
TheNetherWatcher:fix/format-number-rounding
Open

TheNetherWatcher wants to merge 1 commit into
jedib0t:mainfrom
TheNetherWatcher:fix/format-number-rounding

Conversation

@TheNetherWatcher

Copy link
Copy Markdown
Contributor

Proposed Changes

  • formatNumber picks the unit from the absolute value, so negative values get the same notation as positive ones (-1500000 → -1.50M instead of -1500000).
  • If rounding to 2 decimals would print 1000.00 in the chosen unit, move up to the next unit (999999 → 1.00M instead of 1000.00K). The top unit is unchanged (1500.00PB still works).
  • Added test cases for both, including math.MinInt64.

Fixes #441.

@sonarqubecloud

Copy link
Copy Markdown

@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 41048915935

Coverage remained the same at 100.0%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: 7 of 7 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 5168
Covered Lines: 5168
Line Coverage: 100.0%
Coverage Strength: 1.21 hits per line

💛 - Coveralls

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.

progress: FormatNumber/FormatBytes print 1000.00K for 999999 and ignore negative values

2 participants