mirror of
git://sourceware.org/git/glibc.git
synced 2025-04-18 14:30:43 +08:00
Single-precision remainderf() and quad-precision remainderl() implementation derived from Sun is affected by an issue when the result is +-0. IEEE754 requires that if remainder(x, y) = 0, its sign shall be that of x regardless of the rounding direction. The implementation seems to have assumed that x - x = +0 in all rounding modes, which is not the case. When rounding direction is roundTowardNegative the sign of an exact zero sum (or difference) is −0. Regression tests that triggered this erroneous behavior are added to math/libm-test-remainder.inc. Tested for cross riscv64 and powerpc. Original fix by: Bruce Evans <bde@FreeBSD.org> in FreeBSD's a2ddfa5ea726c56dbf825763ad371c261b89b7c7. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>