diff options
author | Joseph Myers <joseph@codesourcery.com> | 2012-10-30 13:54:50 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2012-10-30 13:54:50 +0000 |
commit | 8627a2329c5e6fc09bf9f0f070a21aca41f2b122 (patch) | |
tree | f1e7aa19f3fe1a9b3f9e403ced782c6f7d612f66 /sysdeps/ieee754/dbl-64 | |
parent | 2a27fd6dae3edec949deda9a55928a0e22c8a8ae (diff) | |
download | glibc-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/dbl-64')
-rw-r--r-- | sysdeps/ieee754/dbl-64/s_fma.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/sysdeps/ieee754/dbl-64/s_fma.c b/sysdeps/ieee754/dbl-64/s_fma.c index 5e21461a4b..108fd66192 100644 --- a/sysdeps/ieee754/dbl-64/s_fma.c +++ b/sysdeps/ieee754/dbl-64/s_fma.c @@ -210,20 +210,14 @@ __fma (double x, double y, 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-106; - if (v.ieee.negative) - return v.d - 0x1p-1074 /* __DBL_DENORM_MIN__ */; - else - return v.d + 0x1p-1074 /* __DBL_DENORM_MIN__ */; - } - else - return v.d * 0x1p-106; + bit. */ + w.d = 0.0; + w.ieee.mantissa1 = ((v.ieee.mantissa1 & 3) << 1) | j; + w.ieee.negative = v.ieee.negative; + v.ieee.mantissa1 &= ~3U; + v.d *= 0x1p-106; + w.d *= 0x1p-2; + return v.d + w.d; } v.ieee.mantissa1 |= j; return v.d * 0x1p-106; |