From c88769dda4199d15267259fd3c9b986e6690a901 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Tue, 17 Dec 2013 13:42:13 +0000 Subject: Fix hypot handling of subnormals (bug 16316, bug 16330). --- sysdeps/ieee754/dbl-64/e_hypot.c | 11 +++++++++++ sysdeps/ieee754/ldbl-128/e_hypotl.c | 11 +++++++++++ sysdeps/ieee754/ldbl-96/e_hypotl.c | 11 +++++++++++ 3 files changed, 33 insertions(+) (limited to 'sysdeps/ieee754') diff --git a/sysdeps/ieee754/dbl-64/e_hypot.c b/sysdeps/ieee754/dbl-64/e_hypot.c index 9f4321efe1..500658d076 100644 --- a/sysdeps/ieee754/dbl-64/e_hypot.c +++ b/sysdeps/ieee754/dbl-64/e_hypot.c @@ -102,6 +102,17 @@ __ieee754_hypot (double x, double y) b *= t1; a *= t1; k -= 1022; + GET_HIGH_WORD (ha, a); + GET_HIGH_WORD (hb, b); + if (hb > ha) + { + t1 = a; + a = b; + b = t1; + j = ha; + ha = hb; + hb = j; + } } else /* scale a and b by 2^600 */ { diff --git a/sysdeps/ieee754/ldbl-128/e_hypotl.c b/sysdeps/ieee754/ldbl-128/e_hypotl.c index f5ab901e6a..01444cfb4e 100644 --- a/sysdeps/ieee754/ldbl-128/e_hypotl.c +++ b/sysdeps/ieee754/ldbl-128/e_hypotl.c @@ -89,6 +89,17 @@ __ieee754_hypotl(long double x, long double y) b *= t1; a *= t1; k -= 16382; + GET_LDOUBLE_MSW64 (ha, a); + GET_LDOUBLE_MSW64 (hb, b); + if (hb > ha) + { + t1 = a; + a = b; + b = t1; + j = ha; + ha = hb; + hb = j; + } } else { /* scale a and b by 2^9600 */ ha += 0x2580000000000000LL; /* a *= 2^9600 */ hb += 0x2580000000000000LL; /* b *= 2^9600 */ diff --git a/sysdeps/ieee754/ldbl-96/e_hypotl.c b/sysdeps/ieee754/ldbl-96/e_hypotl.c index 7895488848..d3152f91e5 100644 --- a/sysdeps/ieee754/ldbl-96/e_hypotl.c +++ b/sysdeps/ieee754/ldbl-96/e_hypotl.c @@ -89,6 +89,17 @@ long double __ieee754_hypotl(long double x, long double y) b *= t1; a *= t1; k -= 16382; + GET_LDOUBLE_EXP (ea, a); + GET_LDOUBLE_EXP (eb, b); + if (eb > ea) + { + t1 = a; + a = b; + b = t1; + j = ea; + ea = eb; + eb = j; + } } else { /* scale a and b by 2^9600 */ ea += 0x2580; /* a *= 2^9600 */ eb += 0x2580; /* b *= 2^9600 */ -- cgit v1.2.3-70-g09d2