about summary refs log tree commit diff
path: root/sysdeps/ieee754/ldbl-128ibm/s_floorl.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/ieee754/ldbl-128ibm/s_floorl.c')
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_floorl.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_floorl.c b/sysdeps/ieee754/ldbl-128ibm/s_floorl.c
index e8ef6e849d..2be5e28698 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_floorl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_floorl.c
@@ -18,9 +18,6 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
-/* This has been coded in assembler because GCC makes such a mess of it
-   when it's coded in C.  */
-
 #include <math.h>
 #include <fenv.h>
 #include <math_ldbl_opt.h>
@@ -44,18 +41,22 @@ __floorl (x)
   u.d = x;
 
   if (fabs (u.dd[0]) < TWO52)
-    {     
+    {
+      double high = u.dd[0];
       fesetround(FE_DOWNWARD);
-      if (u.dd[0] > 0.0)
+      if (high > 0.0)
 	{
-	  u.dd[0] += TWO52;
-	  u.dd[0] -= TWO52;
+	  high += TWO52;
+	  high -= TWO52;
+          if (high == -0.0) high = 0.0;
 	}
-      else if (u.dd[0] < 0.0)
+      else if (high < 0.0)
 	{
-	  u.dd[0] -= TWO52;
-	  u.dd[0] += TWO52;
+	  high -= TWO52;
+	  high += TWO52;
+          if (high == 0.0) high = -0.0;
 	}
+      u.dd[0] = high;
       u.dd[1] = 0.0;
       fesetround(mode);
     }