temporal icon indicating copy to clipboard operation
temporal copied to clipboard

TotalTimeDuration needs

Open Manishearth opened this issue 2 months ago • 1 comments

This is related to https://github.com/boa-dev/temporal/issues/613 but is not the same issue

This is the reason behind test failures in built-ins/Temporal/Duration/prototype/total/precision-exact-mathematical-values-6 and built-ins/Temporal/Duration/prototype/total/precision-exact-mathematical-values-7.

  1. Let divisor be the value in the "Length in Nanoseconds" column of the row of Table 21 whose "Value" column contains unit.
  2. NOTE: The following step cannot be implemented directly using floating-point arithmetic when 𝔽(timeDuration) is not a safe integer. The division can be implemented in C++ with the __float128 type if the compiler supports it, or with software emulation such as in the SoftFP library.
  3. Return timeDuration / divisor.

cc @nekevss

Manishearth avatar Nov 10 '25 22:11 Manishearth

Some options:

  • We use rustc_apfloat (https://docs.rs/rustc_apfloat/latest/rustc_apfloat/ieee/type.Quad.html)
  • We do something like FractionalToDouble from SpiderMonkey https://searchfox.org/firefox-main/source/js/src/builtin/temporal/Temporal.cpp#487

Note that our divisors are from a known, small set. We may be able to also get out of things by e.g. separating out the power of ten division.

Manishearth avatar Nov 10 '25 23:11 Manishearth

This was addressed by #622, correct?

nekevss avatar Dec 04 '25 15:12 nekevss

Yes, I believe so.

Manishearth avatar Dec 04 '25 16:12 Manishearth