News for hackers. Stuff that matters.
Re:Log is non-monotonic in PHP and Lua by lioeters on Thursday July 23, 2026 @03:43PM (#49027011)
Nice, thanks for tracking down those links, fascinating. Apparently being off by 1 ULP is within IEEE 754 floating-point spec, and "effectively negligible".
Re:Log is non-monotonic in PHP and Lua by AlotOfReading on Thursday July 23, 2026 @04:05PM (#49027301)
Correctly rounding transcendental functions is very difficult because of something called the table maker's dilemma, so the standard didn't want to impose a potentially extreme performance cost if they didn't have to.

Correctly rounded single precision functions at a reasonable cost are much easier these days. LLVM 18+ implements them, but the gnu libraries have been slower to improve.

Re:Log is non-monotonic in PHP and Lua by ReactiveJelly on Wednesday July 29, 2026 @01:17AM (#49093664)
"The Table-Maker's Dilemma"

https://people.eecs.berkeley.edu/~wkahan/LOG10HAF.TXT

This is the best source I could find, funny enough the author doesn't explain the name "table maker".

I suppose it's from the parable of a table maker who finds that one leg is too long, so they sand down that leg, only to find that another leg is too long, so they sand that down... slowly sanding away all the legs.

As a simple programmer I don't understand the dilemma. I do understand that sin, tan, sqrt, etc., take one argument, so you can guarantee a certain precision for them, at least in 32-bit floats, whereas a log in arbitrary base has two inputs, so its input space is huge and it's hard to guarantee anything, especially for 64-bit doubles.

If someone could write up a good explanation that could be its own HN post

Re:Log is non-monotonic in PHP and Lua by lifthrasiir on Wednesday July 29, 2026 @02:32AM (#49094065)
The dilemma is hypothetical (because we now know the exact precision requirement for those functions over all 64-bit doubles) but let's assume that we don't know that and also we happen to use decimals instead. What if, some f(x) is known to be, say, 123.4999...9997 with 1,000 fractional digits? You have to calculate at least 1,000 decimal digits of f(x) in order to correctly round, before that we only know it's between 123.4999...999 and 123.5000...001. There seems no mathematical theory that specially prevents this annoying possibility, hence the dilemma.
Re:Log is non-monotonic in PHP and Lua by dataflow on Wednesday July 29, 2026 @03:57AM (#49094595)
> because we now know the exact precision requirement for those functions over all 64-bit doubles

Do you have a link or something on this?

Re:Log is non-monotonic in PHP and Lua by lifthrasiir on Wednesday July 29, 2026 @05:37AM (#49095208)
I'm on a mobile right now so I can't give the exact paper link but you can learn about the CORE-MATH project [1].

[1] https://core-math.gitlabpages.inria.fr/

Re:Log is non-monotonic in PHP and Lua by lioeters on Wednesday July 29, 2026 @05:59AM (#49095363)
> CORE-MATH Mission: provide on-the-shelf high performance open-source mathematical functions with correct rounding that can be integrated into current mathematical libraries (GNU libc, Intel Math Library, AMD Libm, Newlib, OpenLibm, Musl, Apple Libm, llvm-libc, Microsoft libm, CUDA libm, ROCm)

That's beautiful. Here's the Git repo with implementation.

https://gitlab.inria.fr/core-math/core-math/-/blob/master/RE...

Re:Log is non-monotonic in PHP and Lua by toast0 on Wednesday July 29, 2026 @01:54AM (#49093859)
> the author doesn't explain the name "table maker".

I suppose that parable fits, but also there is the dilema of someone making a table of (results) of transcendental functions. In the before times, most people got their sines and cosines and logs and what not by looking them up in tables. And someone has to make those tables. The example given where rounding to some specific number of digits depends on how many digits you calculate to is deeply unsatisfying, especially if you wanted to make a table for other people to use to lookup the results of functions.

Re:Log is non-monotonic in PHP and Lua by jhgb on Wednesday July 29, 2026 @03:12AM (#49094317)
I simply assumed the tables in question were log tables. (No, not that kind of log.)
Re:Log is non-monotonic in PHP and Lua by thirdhaf on Wednesday July 29, 2026 @01:46AM (#49093826)
My assumption is it's referring to mathematical tables and the historical makers of them. https://en.wikipedia.org/wiki/Mathematical_table