strange error in clog

Alexander Monakov amonakov@ispras.ru
Tue Apr 22 14:04:02 GMT 2025


On Tue, 22 Apr 2025, Paul Zimmermann wrote:

>        Hi,
> 
> while trying to pre-integrate the binary64 atan2 function from CORE-MATH
> into the GNU libc [1], my student Saban (in cc) got errors with "make check":
> 
> testing double (without inline functions)
> Failure: Real part of: clog (0x1p+0 + 0x1.23456789p-1000 i): Exception "Underflow" not set
> Failure: Real part of: clog (0x1p+0 + 0xf.ffffffffffff8p-1004 i): Exception "Underflow" not set
> ...
> 
> Indeed there should be an underflow for the real part, but we don't understand
> why we get such an error, since the real part should be computed via
> log(sqrt(x^2+y^2)) [2] and thus should not depend on the new atan2() code.
> (The imaginary part should be computed by atan2(), but there should be no
> underflow there.)
> 
> Any idea what is wrong?

Possibly fma contraction is done for x^2+y^2, resulting in fma(y, y, x*x),
which is not underflowing (x*x is non-zero, 'y' does not matter)?

Alexander


More information about the Libc-alpha mailing list