News for hackers. Stuff that matters.
Re:Log is non-monotonic in PHP and Lua by yeputons on Wednesday July 29, 2026 @04:45AM (#49094875)
> On the contrary, IEEE floating point results are precisely specified to produce the closest representable value to the mathematically exact result.

Not sure about Rust, but C++ only guarantees that for four arithmetic operations and `sqrt`. Not `pow`, not `log`. Not even when when all inputs/outputs are integers. Sometimes you can even get `(int)pow(10, 2) == 99`, which I believe is fully standard-compliant.

Re:Log is non-monotonic in PHP and Lua by kaathewise on Wednesday July 29, 2026 @05:39AM (#49095220)
Yeah, those operations (+fma) are the only ones for which IEEE 754 mandates correct rounding.

Calculating correct rounding for other functions without hardware support is both challenging to implement and is often really slow. And that's before one gets into special functions. Or, even worse, inverses of special functions. Sometimes you might be lucky when those don't over/underflow around the edges of the domain

Re:Log is non-monotonic in PHP and Lua by inigyou on Wednesday July 29, 2026 @06:59AM (#49095820)
It's still challenging to implement with hardware support but you don't notice because it challenges Intel instead of you. There is a reason that no instruction set since x87 implements transcendentals - and x87 did them in microcode.
Re:Log is non-monotonic in PHP and Lua by kaathewise on Wednesday July 29, 2026 @07:11AM (#49095907)
True!

Older numerical libraries such as cephes had to work with heterogeneous non-IEEE floating point implementations: you can still see remnants of VAX tests in the docs, for example. That, too, must've been quite a struggle