Apply exponent grouping for scientific notation patterns - #1281
Open
lin-hongkuan wants to merge 1 commit into
Open
lin-hongkuan wants to merge 1 commit into
lin-hongkuan wants to merge 1 commit into
Conversation
akx
requested changes
Sep 18, 2026
akx
left a comment
Member
There was a problem hiding this comment.
Could you show another implementation of the CLDR/LDML doing this? With this sort of change I'd really love to be sure.
| if max_int > min_int and max_int > 1: | ||
| lead_shift = exp % max_int | ||
| else: | ||
| lead_shift = max([1, min_int]) - 1 |
Member
There was a problem hiding this comment.
Useless list construction, might as well do
Suggested change
| lead_shift = max([1, min_int]) - 1 | |
| lead_shift = max(1, min_int) - 1 |
This branch has not been deployed
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.
Fixes #1026.
LDML scientific notation treats the maximum number of integer digits in a scientific pattern as the exponent grouping size. Babel only shifted by the minimum integer digit count, so patterns such as
##0.####E0formatted12345as1.2345E4instead of12.345E3.This changes the scientific notation normalization to use the maximum integer digit count when it is larger than the minimum, while preserving the existing fixed-minimum behavior for patterns without exponent grouping.
Checks run locally:
python setup.py import_cldrpython -m pytest tests\test_numbers.py tests\test_numbers_format_decimal.py -q(140 passed)python -m pre_commit run --files babel\numbers.py tests\test_numbers.py tests\test_numbers_format_decimal.py --show-diff-on-failure --color=neverPYTHONUTF8=1 python -m pytest -q(7478 passed, 8 skipped, 2 xfailed)