Repository navigation
Use Intl mathematical values in ConvertUnitValue - #125
jessealama wants to merge 14 commits into
Conversation
|
gibson042
left a comment
There was a problem hiding this comment.
I thought there was too much resistance to mathematical-value multiplication and division, but am happy if that's not the case.
There was a problem hiding this comment.
With #115, not all results become exact; for example, 0.3𝔽 * 3 still equals 0.8999999999999999𝔽. I think the way to specify this is to use Math.fma.
EDIT: This example is describing what the behavior should be, which is not what this PR specifies.
Where in the changes of this PR do you see any step that could result in that calculation? |
This PR appears to do all math in MV space, including converting a float to an Intl MV, which treats the float as the shortest decimal, not the full-precision floating point MV. However, that cannot be implemented without decimal arithmetic, which is a hard no from engines. The approach in #115 is a compromise that gets us closer to exact arithmetic by removing the double-rounding in |
eemeli
left a comment
There was a problem hiding this comment.
This seems like quite a surprising change, and would require explicit implementer approval before we apply it. Introducing a requirement for an implementation to be able to do decimal multiplication is... a lot. And rather like with Math.fma(), it's a capability that, if approved, should not only be available in this one corner of the spec.
So if you would like us to do this, I think you need to first present a separate proposal introducing that capability to the language, and then we use it here.
|
The thinking behind these changes was to imagine a world where we had |
642ff63 to
865de77
Compare
Right. We can't require implementors to do more than |
|
Let me qualify that comment: The objective of FMA is to avoid multi-rounding of floats. It might be possible to specify that behavior without using Math.fma, so long as it is done carefully. See some of my more recent comments in #115. |
865de77 to
97bbd42
Compare
Co-authored-by: Richard Gibson <richard.gibson@gmail.com>
Co-authored-by: Richard Gibson <richard.gibson@gmail.com>
ConvertUnitValue now takes an Intl MV Record and returns one, so the operation's header and its two callers agree with the algorithm body. The variable name in the offset branch and the missing underscores on the result variable are fixed along the way.
ConvertUnitValue relies on positive factors to preserve negative zero in the purely multiplicative case. Nothing in the CLDR conversion data promises that, so state the assumption as an assertion.
Related to #115 , use (Intl) mathematical values in
ConvertUnitValueto remove at least one step of rounding. Before:Now: