about summary refs log tree commit diff
path: root/sysdeps/ieee754/dbl-64/s_fmaf.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2012-09-29 18:31:54 +0000
committerJoseph Myers <joseph@codesourcery.com>2012-09-29 18:31:54 +0000
commit8ec5b01346114da38e806ca1867da688d3a360e2 (patch)
tree8a55bd704c2a6ca8164202217e2048bb33a7dacb /sysdeps/ieee754/dbl-64/s_fmaf.c
parentb1fa802e1ad4104060fe93b4b3b078ba46be0933 (diff)
downloadglibc-8ec5b01346114da38e806ca1867da688d3a360e2.tar.gz
glibc-8ec5b01346114da38e806ca1867da688d3a360e2.tar.xz
glibc-8ec5b01346114da38e806ca1867da688d3a360e2.zip
Fix sign of exact zero return from fma (bug 14638).
Diffstat (limited to 'sysdeps/ieee754/dbl-64/s_fmaf.c')
-rw-r--r--sysdeps/ieee754/dbl-64/s_fmaf.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/sysdeps/ieee754/dbl-64/s_fmaf.c b/sysdeps/ieee754/dbl-64/s_fmaf.c
index e7a0650f0f..a4f12d9f76 100644
--- a/sysdeps/ieee754/dbl-64/s_fmaf.c
+++ b/sysdeps/ieee754/dbl-64/s_fmaf.c
@@ -32,8 +32,15 @@ float
 __fmaf (float x, float y, float z)
 {
   fenv_t env;
+
   /* Multiplication is always exact.  */
   double temp = (double) x * (double) y;
+
+  /* Ensure correct sign of an exact zero result by performing the
+     addition in the original rounding mode in that case.  */
+  if (temp == -z)
+    return (float) temp + z;
+
   union ieee754_double u;
 
   libc_feholdexcept_setround (&env, FE_TOWARDZERO);