diff options
author | Jakub Jelinek <jakub@redhat.com> | 2010-10-15 15:26:06 -0400 |
---|---|---|
committer | Ulrich Drepper <drepper@gmail.com> | 2010-10-15 15:26:06 -0400 |
commit | 3e692e0518b4f4679352d25102bd47cf3f85c592 (patch) | |
tree | a3f4cefdf037d6c72a8267277dbe0bd0922f2d3e /sysdeps/ieee754/ldbl-96/s_fma.c | |
parent | f3f7372de1401b99f0a318ce09caf73e42d6f022 (diff) | |
download | glibc-3e692e0518b4f4679352d25102bd47cf3f85c592.tar glibc-3e692e0518b4f4679352d25102bd47cf3f85c592.tar.gz glibc-3e692e0518b4f4679352d25102bd47cf3f85c592.tar.bz2 glibc-3e692e0518b4f4679352d25102bd47cf3f85c592.zip |
Implement fmal, some fma bugfixes
Diffstat (limited to 'sysdeps/ieee754/ldbl-96/s_fma.c')
-rw-r--r-- | sysdeps/ieee754/ldbl-96/s_fma.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/sysdeps/ieee754/ldbl-96/s_fma.c b/sysdeps/ieee754/ldbl-96/s_fma.c index 90c6d1f29d..6c7e9d0d36 100644 --- a/sysdeps/ieee754/ldbl-96/s_fma.c +++ b/sysdeps/ieee754/ldbl-96/s_fma.c @@ -30,11 +30,20 @@ double __fma (double x, double y, double z) { + if (__builtin_expect (isinf (z), 0)) + { + /* If z is Inf, but x and y are finite, the result should be + z rather than NaN. */ + if (finite (x) && finite (y)) + return (z + x) + y; + return (x * y) + z; + } + /* Multiplication m1 + m2 = x * y using Dekker's algorithm. */ #define C ((1ULL << (LDBL_MANT_DIG + 1) / 2) + 1) - long double x1 = x * C; - long double y1 = y * C; - long double m1 = x * y; + long double x1 = (long double) x * C; + long double y1 = (long double) y * C; + long double m1 = (long double) x * y; x1 = (x - x1) + x1; y1 = (y - y1) + y1; long double x2 = x - x1; |