Repository navigation
Pick formatter precision from the rounded value, not the raw one - #418
Merged
chattymin merged 1 commit intoOct 5, 2026
Merged
Conversation
6 of 10 tasks
donky-ey
pushed a commit
to donky-ey/PokeDexBar
that referenced
this pull request
Oct 15, 2026
… (upstream chattymin#418) 79.96 printed as "80.0%" and 99.96 as "$100.0": the branch compared the raw value while the format rounded it past the cutoff. Branch on the rounded string instead.
Strongorange
added a commit
to Strongorange/PokeTokenBar-windows
that referenced
this pull request
Oct 19, 2026
Port macOS chattymin#365 and chattymin#418: compact K/M switch to the next unit when rounding would display 1000.0 (999,950 shows as 1M, not 1000K), and percent/cost tiers are picked from the rounded string instead of the raw value (79.96 shows as 80%, 99.96 as \, 9,999.6 as \.0K).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #417.
TokenFormatter.percentandcostCompactchose their precision from the raw value and rounded afterwards. When rounding crossed a boundary, the output contradicted the choice:79.96became80.0%,99.96became$100.0, and9_999.6became$10000instead of$10.0K.Both functions now format with the bucket's precision first and pick the bucket from the formatted value. Output for every non-boundary value is unchanged: the existing
testFormatterEdgesassertions still pass as-is.Type of change
UI changes
5h 80.0%next to7d 88%; recap▲13.0%; cost$100.0/$100005h 80%,▲13%,$100/$10.0KValidation
LocalUsageCacheTests.testFormatterRoundingBoundarieswith pairs just above and just below each boundary (79.96/79.94, 99.96/99.94, 9_999.6/9_999.4, plus 99.97 and 0.04). On unfixedmainit fails with 5 failures. With the fix, all pass.swift test: 1385 tests, 0 failures (17 skipped, as onmain).L.difficultyValuehas the same shape, butsnapDifficultysnaps every slider value to 2 significant digits, so no input can round across its boundaries. Left unchanged and noted in the defect log.Checklist
swift buildandswift testpass locally