]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
PowerPC: Fix modf/modff optimization return sign
authorAdhemerval Zanella <azanella@linux.vnet.ibm.com>
Sat, 8 Mar 2014 17:24:32 +0000 (11:24 -0600)
committerAdhemerval Zanella <azanella@linux.vnet.ibm.com>
Sat, 8 Mar 2014 17:24:32 +0000 (11:24 -0600)
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.

ChangeLog
sysdeps/powerpc/power5+/fpu/s_modf.c
sysdeps/powerpc/power5+/fpu/s_modff.c

index 4071f087d18e655dcd6ab10766d3cdcc4249f7a6..526617720f78866398328e423ecef3e39fb7e792 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2014-03-03  Adhemerval Zanella  <azanella@linux.vnet.ibm.com>
+
+       * sysdeps/powerpc/power5+/fpu/s_modf.c (__modf): Fix to return correct
+       sign in non default rounding modes.
+       * sysdeps/powerpc/power5+/fpu/s_modff.c (__modff): Likewise.
+
 2014-03-08  Joseph Myers  <joseph@codesourcery.com>
 
        * math/libm-test.inc (ALL_RM_TEST): New macro.
index eb469f7647ca72d4b383bfcf155bbead5607950e..06da3ac8091005d76dc581dd977ba0a58e1ad5bb 100644 (file)
@@ -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)
index e4fe857d29311939599fce481430cf63dd528049..af17becf13139a1e09f8581b6acaa26720ebd1f1 100644 (file)
@@ -35,12 +35,12 @@ __modff (float x, float *iptr)
   if (x >= 0.0)
     {
       *iptr = __floorf (x);
-      return (x - *iptr);
+      return __copysignf (x - *iptr, x);
     }
   else
     {
       *iptr = __ceilf (x);
-      return (x - *iptr);
+      return __copysignf (x - *iptr, x);
     }
 }
 weak_alias (__modff, modff)