From 54b46a4b3efd179ccbbf8e342e64391e2b590f1b Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Sat, 8 Mar 2014 11:24:32 -0600 Subject: PowerPC: Fix modf/modff optimization return sign This patch fix the optimized powerpc-fpu modf/modff implementation when using in non-default rounding mode where the zero sign is not as expected. It fixes the libm testsuite tests modf_downward (0) == 0.00000000000000000000e+00 modf_downward (20) == 0.00000000000000000000e+00 modf_downward (21) == 0.00000000000000000000e+00 Where the sign returned was negative. --- sysdeps/powerpc/power5+/fpu/s_modf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sysdeps/powerpc/power5+/fpu/s_modf.c') diff --git a/sysdeps/powerpc/power5+/fpu/s_modf.c b/sysdeps/powerpc/power5+/fpu/s_modf.c index eb469f7647..06da3ac809 100644 --- a/sysdeps/powerpc/power5+/fpu/s_modf.c +++ b/sysdeps/powerpc/power5+/fpu/s_modf.c @@ -36,12 +36,12 @@ __modf (double x, double *iptr) if (x >= 0.0) { *iptr = __floor (x); - return (x - *iptr); + return __copysign (x - *iptr, x); } else { *iptr = __ceil (x); - return (x - *iptr); + return __copysign (x - *iptr, x); } } weak_alias (__modf, modf) -- cgit 1.4.1