ladybird/Meta/Lagom/Tools/CodeGenerators/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
..
CMakeLists.txt LibUnicode: Move number formatting code generator to UnicodeNumberFormat 2021-11-12 20:46:38 +00:00
GenerateUnicodeData.cpp Everywhere: Pass AK::StringView by value 2021-11-11 01:27:46 +01:00
GenerateUnicodeLocale.cpp LibUnicode: Ensure UnicodeNumberFormat is aware of default content 2021-11-13 11:52:45 +00:00
GenerateUnicodeNumberFormat.cpp LibJS+LibUnicode: Fix computation of compact pattern exponents 2021-11-16 00:56:55 +00:00
GeneratorUtil.h LibUnicode: Ensure UnicodeNumberFormat is aware of default content 2021-11-13 11:52:45 +00:00