fix(@formatjs/intl-numberformat): handle massive numbers, fix #4236#5782
Closed
fix(@formatjs/intl-numberformat): handle massive numbers, fix #4236#5782
Conversation
Merge activity
|
graphite-app bot
pushed a commit
that referenced
this pull request
Jan 2, 2026
…5782) ### TL;DR Fix compact number formatting for very large numbers that exceed available locale patterns. ### What changed? - Modified `ComputeExponentForMagnitude` to correctly calculate the exponent when a number exceeds the maximum threshold - Updated `getCompactDisplayPattern` to use the largest available pattern when formatting numbers that exceed the available magnitude patterns - Added fallback logic for both currency and non-currency compact formatting ### How to test? Run the new test cases that verify compact notation works correctly with very large numbers: - Verify that numbers like 1 trillion (1e12) format as "1T" - Verify that numbers exceeding 1000 trillion (1e15) format correctly using the largest available pattern (e.g., "1000T") - Verify that even larger numbers (e.g., 10 quadrillion) continue to use the appropriate suffix ### Why make this change? Fixes issue #4236 where very large numbers (greater than 1000 trillion) were not formatting correctly with compact notation. Previously, when a number exceeded the largest available threshold in locale data, the formatting would fail to apply the correct exponent calculation. This change ensures that even numbers beyond the explicit thresholds in locale data are formatted consistently using the largest available pattern.
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.
TL;DR
Fix compact number formatting for very large numbers that exceed available locale patterns.
What changed?
ComputeExponentForMagnitudeto correctly calculate the exponent when a number exceeds the maximum thresholdgetCompactDisplayPatternto use the largest available pattern when formatting numbers that exceed the available magnitude patternsHow to test?
Run the new test cases that verify compact notation works correctly with very large numbers:
Why make this change?
Fixes issue #4236 where very large numbers (greater than 1000 trillion) were not formatting correctly with compact notation. Previously, when a number exceeded the largest available threshold in locale data, the formatting would fail to apply the correct exponent calculation. This change ensures that even numbers beyond the explicit thresholds in locale data are formatted consistently using the largest available pattern.