Bug 281501
| Summary: | [JSC] Fix rounding error for `Intl.DurationFormat` | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Sosuke Suzuki <aosukeke> |
| Component: | JavaScriptCore | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | webkit-bug-importer |
| Priority: | P2 | Keywords: | InRadar |
| Version: | WebKit Nightly Build | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
Sosuke 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
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Sosuke Suzuki
Pull request: https://github.com/WebKit/WebKit/pull/35219
EWS
Committed 285482@main (48d36047a83e): <https://commits.webkit.org/285482@main>
Reviewed commits have been landed. Closing PR #35219 and removing active labels.
Radar WebKit Bug Importer
<rdar://problem/138261569>