From 6e60567b9bbf59b38c72493faf7cc9eb6ce43c64 Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Mon, 10 Dec 2018 12:53:01 +0000 Subject: Change the powf overflow handling This fix is slightly more correct than the previous one (which introduced a 1ulp error when rounding toward zero near the overflow limit) and has slightly smaller code size. --- math/powf.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/math/powf.c b/math/powf.c index 385719b..1149842 100644 --- a/math/powf.c +++ b/math/powf.c @@ -204,8 +204,11 @@ powf (float x, float y) if (WANT_ROUNDING && WANT_ERRNO && ylogx > 0x1.fffffffa3aae2p+6 * POWF_SCALE) /* |x^y| > 0x1.fffffep127, check if we round away from 0. */ - if ((!sign_bias && opt_barrier_float (-ylogx) != -128 * POWF_SCALE) - || (sign_bias && -opt_barrier_float (ylogx) != -128 * POWF_SCALE)) + if ((!sign_bias + && eval_as_float (1.0f + opt_barrier_float (0x1p-25f)) != 1.0f) + || (sign_bias + && eval_as_float (-1.0f - opt_barrier_float (0x1p-25f)) + != -1.0f)) return __math_oflowf (sign_bias); if (ylogx <= -150.0 * POWF_SCALE) return __math_uflowf (sign_bias); -- cgit v1.2.3