summary refs log tree commit diff
path: root/sysdeps/ieee754/ldbl-96/s_fmal.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2012-10-30 13:54:50 +0000
committerJoseph Myers <joseph@codesourcery.com>2012-10-30 13:54:50 +0000
commit8627a2329c5e6fc09bf9f0f070a21aca41f2b122 (patch)
treef1e7aa19f3fe1a9b3f9e403ced782c6f7d612f66 /sysdeps/ieee754/ldbl-96/s_fmal.c
parent2a27fd6dae3edec949deda9a55928a0e22c8a8ae (diff)
downloadglibc-8627a2329c5e6fc09bf9f0f070a21aca41f2b122.tar.gz
glibc-8627a2329c5e6fc09bf9f0f070a21aca41f2b122.tar.xz
glibc-8627a2329c5e6fc09bf9f0f070a21aca41f2b122.zip
Fix fma missing underflows and bad results for some subnormal results (bugs 14152, 14783).
Diffstat (limited to 'sysdeps/ieee754/ldbl-96/s_fmal.c')
-rw-r--r--sysdeps/ieee754/ldbl-96/s_fmal.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/sysdeps/ieee754/ldbl-96/s_fmal.c b/sysdeps/ieee754/ldbl-96/s_fmal.c
index d125124286..73104914b3 100644
--- a/sysdeps/ieee754/ldbl-96/s_fmal.c
+++ b/sysdeps/ieee754/ldbl-96/s_fmal.c
@@ -211,20 +211,14 @@ __fmal (long double x, long double y, long double z)
 	{
 	  /* v.ieee.mantissa1 & 2 is LSB bit of the result before rounding,
 	     v.ieee.mantissa1 & 1 is the round bit and j is our sticky
-	     bit.  In round-to-nearest 001 rounds down like 00,
-	     011 rounds up, even though 01 rounds down (thus we need
-	     to adjust), 101 rounds down like 10 and 111 rounds up
-	     like 11.  */
-	  if ((v.ieee.mantissa1 & 3) == 1)
-	    {
-	      v.d *= 0x1p-128L;
-	      if (v.ieee.negative)
-		return v.d - 0x1p-16445L /* __LDBL_DENORM_MIN__ */;
-	      else
-		return v.d + 0x1p-16445L /* __LDBL_DENORM_MIN__ */;
-	    }
-	  else
-	    return v.d * 0x1p-128L;
+	     bit.  */
+	  w.d = 0.0L;
+	  w.ieee.mantissa1 = ((v.ieee.mantissa1 & 3) << 1) | j;
+	  w.ieee.negative = v.ieee.negative;
+	  v.ieee.mantissa1 &= ~3U;
+	  v.d *= 0x1p-128L;
+	  w.d *= 0x1p-2L;
+	  return v.d + w.d;
 	}
       v.ieee.mantissa1 |= j;
       return v.d * 0x1p-128L;