1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-30 03:12:12 +00:00
serenity/Userland/Libraries/LibJS/Runtime/Intl
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
..
AbstractOperations.cpp Everywhere: Pass AK::StringView by value 2021-11-11 01:27:46 +01:00
AbstractOperations.h LibJS: Change Intl's PatternPartition record to hold a String value 2021-11-12 09:17:08 +00:00
DisplayNames.cpp LibJS: Use implicit ThrowCompletionOr<T> constructor where possible 2021-10-21 09:02:23 +01:00
DisplayNames.h LibJS: Convert DisplayNames AOs to ThrowCompletionOr 2021-09-18 22:59:15 +03:00
DisplayNamesConstructor.cpp LibJS: Convert Intl.DisplayNames functions to ThrowCompletionOr 2021-10-22 23:20:18 +01:00
DisplayNamesConstructor.h LibJS: Convert Intl.DisplayNames functions to ThrowCompletionOr 2021-10-22 23:20:18 +01:00
DisplayNamesPrototype.cpp LibJS+LibUnicode: Generate all styles of currency localizations 2021-11-13 11:52:45 +00:00
DisplayNamesPrototype.h LibJS: Convert Intl.DisplayNames functions to ThrowCompletionOr 2021-10-22 23:20:18 +01:00
Intl.cpp LibJS: Convert Intl.getCanonicalLocales() function to ThrowCompletionOr 2021-10-22 23:20:18 +01:00
Intl.h LibJS: Convert Intl.getCanonicalLocales() function to ThrowCompletionOr 2021-10-22 23:20:18 +01:00
ListFormat.cpp LibJS: Change Intl's PatternPartition record to hold a String value 2021-11-12 09:17:08 +00:00
ListFormat.h LibJS: Convert ListFormat AOs to ThrowCompletionOr 2021-09-18 22:59:15 +03:00
ListFormatConstructor.cpp LibJS: Convert Intl.ListFormat functions to ThrowCompletionOr 2021-10-22 23:20:18 +01:00
ListFormatConstructor.h LibJS: Convert Intl.ListFormat functions to ThrowCompletionOr 2021-10-22 23:20:18 +01:00
ListFormatPrototype.cpp LibJS: Convert Intl.ListFormat functions to ThrowCompletionOr 2021-10-22 23:20:18 +01:00
ListFormatPrototype.h LibJS: Convert Intl.ListFormat functions to ThrowCompletionOr 2021-10-22 23:20:18 +01:00
Locale.cpp LibJS: Move locale_relevant_extension_keys to Intl.Locale 2021-09-12 12:57:17 +01:00
Locale.h LibJS: Move locale_relevant_extension_keys to Intl.Locale 2021-09-12 12:57:17 +01:00
LocaleConstructor.cpp LibJS: Rename PropertyName to PropertyKey 2021-10-24 17:18:07 +02:00
LocaleConstructor.h LibJS: Convert NativeFunction::{call,construct}() to ThrowCompletionOr 2021-10-21 09:02:23 +01:00
LocalePrototype.cpp LibJS: Convert Intl.Locale functions to ThrowCompletionOr 2021-10-22 23:20:18 +01:00
LocalePrototype.h LibJS: Convert Intl.Locale functions to ThrowCompletionOr 2021-10-22 23:20:18 +01:00
NumberFormat.cpp LibJS+LibUnicode: Fix computation of compact pattern exponents 2021-11-16 00:56:55 +00:00
NumberFormat.h LibJS: Implement engineering and scientific number formatting 2021-11-14 17:00:35 +00:00
NumberFormatConstructor.cpp LibJS: Convert Intl.NumberFormat functions to ThrowCompletionOr 2021-10-22 23:20:18 +01:00
NumberFormatConstructor.h LibJS: Convert Intl.NumberFormat functions to ThrowCompletionOr 2021-10-22 23:20:18 +01:00
NumberFormatFunction.cpp LibJS: Define the "name" property on the number format function 2021-11-14 17:00:35 +00:00
NumberFormatFunction.h LibJS: Begin implementing Intl.NumberFormat.prototype.format 2021-11-12 09:17:08 +00:00
NumberFormatPrototype.cpp LibJS: Implement Intl.NumberFormat.prototype.formatToParts 2021-11-13 19:01:25 +00:00
NumberFormatPrototype.h LibJS: Implement Intl.NumberFormat.prototype.formatToParts 2021-11-13 19:01:25 +00:00