4 ms·
AIUI, the IEEE 754 standard does not guarantee exactly-reproducible results for transcendental operations, because of the "table-maker's dilemma" - the mathemat
by zozbot234 7y ago
AIUI, the IEEE 754 standard does not guarantee exactly-reproducible results for transcendental operations, because of the "table-maker's dilemma" - the mathematical fact that given a result that's arbitrarily close to being halfway in-between two floating-point values that differ by one ulp (unit in the last place)[0], it may be computationally infeasible to determine the "correctly" rounded result. So this outcome, while perhaps undesirable from an intuitive POV, is not "wrong" in any real sense.
[0] Assuming round-to-nearest, of course. For directed rounding, the problematic case is a result that's arbitrarily close to some exactly-representable value, but not yet determined to be "apart" from it or not in the rounding sense.
- TAForObvReasons 7y agoThere's a simpler explanation: IEEE 754 does not require the operations in question to be defined. They are spelled out in Section 9 (Recommended operations). There's some corner-case guidance (for example, divideByZero for log(0)), but they are implementation-dependent and different JS engines producing slightly different values are all in compliance with the actual requirements.
- titzer 7y agoIt's worth pointing out that some programming languages do indeed dictate precision for more advanced operations. E.g. Java requires Math.sin to be precise to 1up: https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#sin-double- https://docs.oracle.com/javase/8/docs/api/java/lang/Math.htm...
- lifthrasiir 7y ago1 ulp precision means that there are at most two possible results from given operations. Without an explicit guarantee (probably impossible, as this would essentially pin the algorithm down) they are still not reproducible.