From 8627a2329c5e6fc09bf9f0f070a21aca41f2b122 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Tue, 30 Oct 2012 13:54:50 +0000 Subject: Fix fma missing underflows and bad results for some subnormal results (bugs 14152, 14783). --- sysdeps/ieee754/ldbl-96/s_fmal.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'sysdeps/ieee754/ldbl-96') 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; -- cgit 1.4.1