fix(pulse): fmtHero renders negative amounts as unabridged digits - #1778
Closed
takanorinishida wants to merge 1 commit into
Closed
fix(pulse): fmtHero renders negative amounts as unabridged digits#1778takanorinishida wants to merge 1 commit into
takanorinishida wants to merge 1 commit into
Conversation
fmtHero()'s magnitude thresholds (>= 1_000_000, >= 10_000, >= 1_000) are checked against the signed value, so any negative number fails every branch and falls through to the last one, which was written assuming n was already known-small. Net (Overall tab) commonly goes negative when spending exceeds income, so a K/M-abbreviated sibling KPI like "$2.1M" ends up next to "$-2,120,000" instead of "-$2.1M". Threshold on Math.abs(n) instead and prepend the sign once, before the currency symbol. Positive inputs are byte-identical (sign is the empty string); this only changes output for values that were already rendering as long unformatted digit strings. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NVzLJHrJPj5Phmh1vaLUBV
Owner
|
Thanks @takanorinishida — the fmtHero negative-amount abridging fix. Ported into the source tree (the public repo is generated from it, so I'm closing this here), credited by number at the fix site. Ships in the next release. |
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.
fmtHero()'s magnitude thresholds (>= 1_000_000,>= 10_000,>= 1_000) are checked against the signed value, so any negative number fails every branch and falls through to the last one, which was written assumingnwas already known-small. Net (Overall tab) commonly goes negative when spending exceeds income, so a K/M-abbreviated sibling KPI like "$2.1M" ends up next to "$-2,120,000" instead of "-$2.1M".Fix
Threshold on
Math.abs(n)instead and prepend the sign once, before the currency symbol.Non-destructive
Positive inputs are byte-identical (sign is the empty string); this only changes output for values that were already rendering as long unformatted digit strings.
Verification
Standalone checks:
fmtHero(2120000)→$2.1M(unchanged),fmtHero(-2120000)→-$2.1M(was$-2,120,000), plus the K/thousands/zero boundary cases, all matching.🤖 Generated with Claude Code