Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 501d1f661f978612df3435a8631f939465a82ab1
      
https://github.com/WebKit/WebKit/commit/501d1f661f978612df3435a8631f939465a82ab1
  Author: Sosuke Suzuki <[email protected]>
  Date:   2026-09-26 (Sat, 26 Sep 2026)

  Changed paths:
    A JSTests/stress/intl-durationformat-negative-subsecond-sign.js
    M Source/JavaScriptCore/runtime/IntlDurationFormat.cpp

  Log Message:
  -----------
  [JSC] `Intl.DurationFormat` drops the minus sign of a fraction between -1 and 0
https://bugs.webkit.org/show_bug.cgi?id=325247

Reviewed by Yusuke Suzuki.

new Intl.DurationFormat("en", { seconds: "numeric" }).format({ milliseconds: 
-500 })
returns "0.5" instead of "-0.5", and formatToParts() has no minusSign part.

When seconds, milliseconds, or microseconds absorbs the smaller units as a
fraction, buildDecimalFormat splits the nanoseconds into an integer part and a
fraction, and only the integer part carries the sign. A value between -1 and 0
reaches ICU as ".500000000". Stop splitting and pass the nanoseconds with a
decimal exponent ("-500000000E-9"), which unumf_formatDecimal accepts as a
numeric string [1].

[1]: https://speleotrove.com/decimal/daconvs.html

Test: JSTests/stress/intl-durationformat-negative-subsecond-sign.js

* JSTests/stress/intl-durationformat-negative-subsecond-sign.js: Added.
(shouldBe):
(format):
(parts):
* Source/JavaScriptCore/runtime/IntlDurationFormat.cpp:
(JSC::int128ToString):
(JSC::buildDecimalFormat):

Canonical link: https://commits.webkit.org/321988@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to