[PATCH v4 17/21] math: Remove the SVID error handling from tgammaf
Wilco Dijkstra
Wilco.Dijkstra@arm.com
Wed Oct 29 21:41:36 GMT 2025
Hi Adhemerval,
+ /* tgamma(x) overflows for:
+ * 0 <= x < 0x1p-128 whatever the rounding mode
+ * x = 0x1p-128 and rounding to nearest or away from zero
+ (in which case the result is +Inf)
+ * -0x1p-128 <= x <= 0 whatever the rounding mode
+ */
+ if (fabsf (x) < 0x1p-128f ||
+ (x == 0x1p-128f && r > 0x1.fffffep+127f) || x == -0x1p-128f)
+ errno = ERANGE; /* overflow */
It doesn't look like this could be added to the exception table, but
wouldn't it be simpler to check whether final result r is infinite?
if (is_inf (asuint (r)) return __math_oflowf (t >> 31);
- return math_narrow_eval (x * 0x1p127f);
+ return __math_oflowf_value (math_narrow_eval (x * 0x1p127f));
Why not just use return __math_oflowf (0);
if (x == 0.0f)
- return 1.0f / x;
+ return __math_oflowf_value (1.0f / x);
Possibly still use __math_oflowf (t >> 31)?
- return math_narrow_eval (0x1p-127f * sgn[k & 1]);
+ return __math_oflowf_value (math_narrow_eval (0x1p-127f * sgn[k & 1]));
Really? It's underflow, just use return __math_uflowf (k & 1);
+ if (fabsf (r) < 0x1p-126f)
+ errno = ERANGE; // underflow
That should be if (__glibc_unlikely (r == 0)) return __math_uflowf (rt >> 63);
Cheers,
Wilco
More information about the Libc-alpha
mailing list