tc39 / proposal-decimal

Built-in exact decimal numbers for JavaScript
http://tc39.es/proposal-decimal/
497 stars 18 forks source link

Indeterminate forms #110

Closed waldemarhorwat closed 4 months ago

waldemarhorwat commented 7 months ago

Editorial bugs: In a number of places the proposal mentions converting Decimal ±∞ to Mathematical Values. That's forbidden by the current ECMAScript spec. Those can be converted to Extended Mathematical Values, but then the proposal mentions performing operations that can produce indeterminate forms such as equality, which are also not allowed.

jessealama commented 7 months ago

Right, Extended Mathematical Values is what was intended. Good spot.

Do I understand the point about indeterminate forms correctly that comparing a NaN value with any value might produce undefined instead of a boolean value? In an earlier version of the spec, we had a cmp operation, à la IEEE 754's compare operation (which might produce an indeterminate value, which I had modeled by returning undefined), but in the current spec, cmp has been replaced with lessThan and equals. The current spec text may contain traces of that compare.

waldemarhorwat commented 7 months ago

One can ask whether a real number is less than the Extended Mathematical Value +∞, but the question of whether an Extended Mathematical Value +∞ is equal, less than, or greater than an Extended Mathematical Value +∞ is an indeterminate form and has no well-defined answer. There are mathematical systems, for example ordinal numbers, that allow one to rank and compare mathematical infinities, but the ECMAScript spec does not use them. The spec does not say which kind of mathematical infinity +∞ is, and anything that relies on an answer to that question is considered a spec error.

jessealama commented 7 months ago

related to #116

jessealama commented 4 months ago

This has been taken care of now (mainly in #158), where we handle NaNs and infinities properly.