[webkit-changes] [WebKit/WebKit] 48d360: [JSC] Fix rounding error for `Intl.DurationFormat`
SUZUKI Sosuke
noreply at github.com
Sat Oct 19 19:47:51 PDT 2024
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 48d36047a83e40ddfa90ea614825f0f772a4f4e0
https://github.com/WebKit/WebKit/commit/48d36047a83e40ddfa90ea614825f0f772a4f4e0
Author: Sosuke Suzuki <aosukeke at gmail.com>
Date: 2024-10-19 (Sat, 19 Oct 2024)
Changed paths:
A JSTests/stress/intl-durationformat-rounding-errors.js
M JSTests/test262/expectations.yaml
M Source/JavaScriptCore/runtime/ISO8601.cpp
M Source/JavaScriptCore/runtime/ISO8601.h
M Source/JavaScriptCore/runtime/IntlDurationFormat.cpp
Log Message:
-----------
[JSC] Fix rounding error for `Intl.DurationFormat`
https://bugs.webkit.org/show_bug.cgi?id=281501
Reviewed by Yusuke Suzuki.
Our `Intl.DurationFormat` is affected by rounding errors because each unit is summed as a double.
Additionally, very large values cannot fit within a double.
This patch introduces the following changes:
- Each unit is summed using `Int128`.
- Since `Int128` values cannot be formatted with ICU’s `unumf_formatDouble`[1], so we build a
decimal-formatted string from the `Int128` value and use `unumf_formatDecimal`[2] for formatting.
[1]: https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/unumberformatter_8h.html#a54193ed406316485803e3dac3a96615f
[2]: https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/unumberformatter_8h.html#a6183aa03b43b63b231341770035bace9
* JSTests/stress/intl-durationformat-rounding-errors.js: Added.
(sameValue):
(throw.new.Error):
* JSTests/test262/expectations.yaml:
* Source/JavaScriptCore/runtime/ISO8601.cpp:
(JSC::ISO8601::Duration::totalNanoseconds const):
(JSC::ISO8601::isValidDuration):
* Source/JavaScriptCore/runtime/ISO8601.h:
* Source/JavaScriptCore/runtime/IntlDurationFormat.cpp:
(JSC::int128ToString):
(JSC::buildDecimalFormat):
(JSC::collectElements):
Canonical link: https://commits.webkit.org/285482@main
To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications
More information about the webkit-changes
mailing list