aboutsummaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2012-11-22 15:00:35 +0000
committerJoseph Myers <joseph@codesourcery.com>2012-11-22 15:00:35 +0000
commitc60d3bf2fa54298f2dcdea1cceda63e0c0b14ae3 (patch)
tree80202dcf5552e575932f18ea1d9ed0cb3dfa42c8 /sysdeps
parentef1e0867c0f6b1a39625f45aa8a8a9d83fe739be (diff)
downloadglibc-c60d3bf2fa54298f2dcdea1cceda63e0c0b14ae3.zip
glibc-c60d3bf2fa54298f2dcdea1cceda63e0c0b14ae3.tar.gz
glibc-c60d3bf2fa54298f2dcdea1cceda63e0c0b14ae3.tar.bz2
Fix sign of inexact zero results for ldbl-128ibm fmal.
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_fmal.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_fmal.c b/sysdeps/ieee754/ldbl-128ibm/s_fmal.c
index a868b8d..6706eb2 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_fmal.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_fmal.c
@@ -1,5 +1,5 @@
/* Compute x * y + z as ternary operation.
- Copyright (C) 2011 Free Software Foundation, Inc.
+ Copyright (C) 2011-2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by David Flaherty <flaherty@linux.vnet.ibm.com>.
@@ -29,6 +29,12 @@ __fmal (long double x, long double y, long double z)
if ((finite ((double)x) && finite ((double)y)) && isinf ((double)z))
return (z);
+ /* If z is zero and x are y are nonzero, compute the result
+ as x * y to avoid the wrong sign of a zero result if x * y
+ underflows to 0. */
+ if (z == 0 && x != 0 && y != 0)
+ return x * y;
+
return (x * y) + z;
}
#ifdef IS_IN_libm