1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-11-17 02:43:26 +03:00

math: Fix pow special case [BZ #33563]

Fix pow (DBL_MAX, 1.0) to return DBL_MAX when rouding upwards without FMA.
This fixes BZ #33563.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
This commit is contained in:
Wilco Dijkstra
2025-10-30 15:24:53 +00:00
parent 8917bd3eb3
commit 0212fc23b0

View File

@@ -147,8 +147,14 @@ specialcase (double_t tmp, uint64_t sbits, uint64_t ki)
/* k > 0, the exponent of scale might have overflowed by <= 460. */ /* k > 0, the exponent of scale might have overflowed by <= 460. */
sbits -= 1009ull << 52; sbits -= 1009ull << 52;
scale = asdouble (sbits); scale = asdouble (sbits);
y = 0x1p1009 * (scale + scale * tmp); y = scale + scale * tmp;
return check_oflow (y); #ifndef __FP_FAST_FMA
/* Special case pow (0x1.fffffffffffffp+1023, 1.0) when rounding up. */
if (WANT_ROUNDING && y == 0x1p15
&& (math_opt_barrier (1.0) + 0x1p-60) != 1.0)
return DBL_MAX;
#endif
return check_oflow (y * 0x1p1009);
} }
/* k < 0, need special care in the subnormal range. */ /* k < 0, need special care in the subnormal range. */
sbits += 1022ull << 52; sbits += 1022ull << 52;