[PATCH v4 13/21] math: Remove the SVID error handling from atan2f

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Fri Oct 31 13:10:34 GMT 2025



On 29/10/25 17:54, Wilco Dijkstra wrote:
> Hi Adhemerval,
> 
> Are we sure there are no other paths that result in underflow
> to zero? Like eg. return 0.0 * sgn[uy >> 31]; case or when 
> calling cr_atan2f_tiny?

Right, I think it would be better to just use the CORE-MATH underflow
check instead of trying to be clever here:

diff --git a/sysdeps/ieee754/flt-32/e_atan2f.c b/sysdeps/ieee754/flt-32/e_atan2f.c
index 1425f918616..5af9a34591b 100644
--- a/sysdeps/ieee754/flt-32/e_atan2f.c
+++ b/sysdeps/ieee754/flt-32/e_atan2f.c
@@ -88,7 +88,11 @@ cr_atan2f_tiny (float y, float x)
       else
        t -= 1;
     }
-  return asdouble (t);
+  double r = asdouble (t);
+  float rf = r;
+  if (__glibc_unlikely (fabsf (rf) < 0x1p-126f))
+    __set_errno (ERANGE);
+  return rf;
 }

 float
@@ -273,7 +277,7 @@ __atan2f (float y, float x)
       r = th + tm;
     }
   float rf = r;
-  if (__glibc_unlikely (rf == 0 && y != 0))
+  if (__glibc_unlikely (fabsf (rf) < 0x1p-126f))
     __set_errno (ERANGE);
   return rf;
 }


More information about the Libc-alpha mailing list