1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-15 09:14:58 +00:00
serenity/Userland/Libraries/LibUnicode
Timothy Flynn 1f546476d5 LibJS+LibUnicode: Fix computation of compact pattern exponents
The compact scale of each formatting rule was precomputed in commit:
be69eae651

Using the formula: compact scale = magnitude - pattern scale

This computation was off-by-one.

For example, consider the format key "10000-count-one", which maps to
"00 thousand" in en-US. What we are really after is the exponent that
best represents the string "thousand" for values greater than 10000
and less than 100000 (the next format key). We were previously doing:

    log10(10000) - "00 thousand".count("0") = 2

Which clearly isn't what we want. Instead, if we do:

    log10(10000) + 1 - "00 thousand".count("0") = 3

We get the correct exponent for each format key for each locale.

This commit also renames the generated variable from "compact_scale" to
"exponent" to match the terminology used in ECMA-402.
2021-11-16 00:56:55 +00:00
..
CharacterTypes.cpp Everywhere: Pass AK::StringView by value 2021-11-11 01:27:46 +01:00
CharacterTypes.h Everywhere: Pass AK::StringView by value 2021-11-11 01:27:46 +01:00
CMakeLists.txt LibUnicode: Add some data related to currency codes 2021-09-11 11:05:50 +01:00
CurrencyCode.cpp LibUnicode: Add some data related to currency codes 2021-09-11 11:05:50 +01:00
CurrencyCode.h LibUnicode: Add some data related to currency codes 2021-09-11 11:05:50 +01:00
Forward.h LibUnicode: Generate primary and secondary number grouping sizes 2021-11-14 10:35:19 +00:00
Locale.cpp LibUnicode: Generate primary and secondary number grouping sizes 2021-11-14 10:35:19 +00:00
Locale.h LibJS+LibUnicode: Fix computation of compact pattern exponents 2021-11-16 00:56:55 +00:00