about summary refs log tree commit diff
path: root/sysdeps/libm-ieee754/s_llroundl.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/libm-ieee754/s_llroundl.c')
-rw-r--r--sysdeps/libm-ieee754/s_llroundl.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/sysdeps/libm-ieee754/s_llroundl.c b/sysdeps/libm-ieee754/s_llroundl.c
index 959b1e3fe9..4a537c871e 100644
--- a/sysdeps/libm-ieee754/s_llroundl.c
+++ b/sysdeps/libm-ieee754/s_llroundl.c
@@ -52,17 +52,20 @@ __llroundl (long double x)
 	  result = j >> (31 - j0);
 	}
     }
-  else if (j0 < (int32_t) (8 * sizeof (long long int)))
+  else if (j0 < (int32_t) (8 * sizeof (long long int)) - 1)
     {
       if (j0 >= 63)
-	result = ((long long int) i0 << (j0 - 31)) | (i1 << (j0 - 63));
+	result = (((long long int) i0 << 32) | i1) << (j0 - 63);
       else
 	{
 	  u_int32_t j = i1 + (0x80000000 >> (j0 - 31));
 	  if (j < i1)
 	    ++i0;
 
-	  result = ((long long int) i0 << (j0 - 31)) | (j >> (63 - j0));
+	  if (j0 == 31)
+	    result = (long long int) i0;
+	  else
+	    result = ((long long int) i0 << (j0 - 31)) | (j >> (63 - j0));
 	}
     }
   else