1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-30 14:38:12 +00:00
serenity/Userland/Libraries/LibJS
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
..
Bytecode LibJS: Convert push_execution_context() to ThrowCompletionOr 2021-11-14 16:14:38 +00:00
Heap LibJS: Prune WeakContainers before freeing HeapBlocks 2021-10-08 19:47:25 +02:00
Runtime LibJS+LibUnicode: Fix computation of compact pattern exponents 2021-11-16 00:56:55 +00:00
Tests LibJS: Implement engineering and scientific number formatting 2021-11-14 17:00:35 +00:00
AST.cpp LibJS: Add support for await expressions 2021-11-10 08:48:27 +00:00
AST.h LibJS: Implement async functions as generator functions in BC mode 2021-11-12 13:01:59 +00:00
CMakeLists.txt LibJS: Implement async functions as generator functions in BC mode 2021-11-12 13:01:59 +00:00
Console.cpp LibJS: Rename CallFrame => ExecutionContext 2021-06-24 19:28:00 +02:00
Console.h Everything: Move to SPDX license identifiers in all files. 2021-04-22 11:22:27 +02:00
Forward.h LibJS: Add support for async functions 2021-11-10 08:48:27 +00:00
Interpreter.cpp LibJS: Convert push_execution_context() to ThrowCompletionOr 2021-11-14 16:14:38 +00:00
Interpreter.h LibJS: Make scoping follow the spec 2021-09-30 08:16:32 +01:00
Lexer.cpp LibJS: Add support for async functions 2021-11-10 08:48:27 +00:00
Lexer.h Everywhere: Pass AK::StringView by value 2021-11-11 01:27:46 +01:00
MarkupGenerator.cpp Everywhere: Pass AK::StringView by value 2021-11-11 01:27:46 +01:00
MarkupGenerator.h Everywhere: Pass AK::StringView by value 2021-11-11 01:27:46 +01:00
Module.cpp LibJS: Add a barebones Module class 2021-09-14 21:41:51 +02:00
Module.h LibJS: Add a barebones Module class 2021-09-14 21:41:51 +02:00
Parser.cpp Everywhere: Pass AK::StringView by value 2021-11-11 01:27:46 +01:00
Parser.h Everywhere: Pass AK::StringView by value 2021-11-11 01:27:46 +01:00
Script.cpp LibJS+LibWeb: Move script parse time logging from JS::Script to LibWeb 2021-09-14 21:41:51 +02:00
Script.h LibJS+LibWeb: Let JS::Script::parse() return a list of errors (on error) 2021-09-14 21:41:51 +02:00
SourceRange.h LibJS: Add missing headers 2021-10-06 23:52:40 +01:00
SourceTextModule.cpp LibJS: Add a barebones SourceTextModule class 2021-09-14 21:41:51 +02:00
SourceTextModule.h LibJS: Add a barebones SourceTextModule class 2021-09-14 21:41:51 +02:00
SyntaxHighlighter.cpp LibJS: Remove unused header includes 2021-08-01 08:10:16 +02:00
SyntaxHighlighter.h LibWeb+LibSyntax: Implement nested syntax highlighters 2021-06-07 14:45:49 +04:30
Token.cpp LibJS: Add support for async functions 2021-11-10 08:48:27 +00:00
Token.h Everywhere: Pass AK::StringView by value 2021-11-11 01:27:46 +01:00