summaryrefslogtreecommitdiff
path: root/libquadmath/math/hypotq.c
diff options
context:
space:
mode:
Diffstat (limited to 'libquadmath/math/hypotq.c')
-rw-r--r--libquadmath/math/hypotq.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/libquadmath/math/hypotq.c b/libquadmath/math/hypotq.c
index 2df317f3681..057901073dc 100644
--- a/libquadmath/math/hypotq.c
+++ b/libquadmath/math/hypotq.c
@@ -89,6 +89,17 @@ hypotq (__float128 x, __float128 y)
b *= t1;
a *= t1;
k -= 16382;
+ GET_FLT128_MSW64 (ha, a);
+ GET_FLT128_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 */
@@ -119,6 +130,8 @@ hypotq (__float128 x, __float128 y)
t1 = 1.0Q;
GET_FLT128_MSW64(high,t1);
SET_FLT128_MSW64(t1,high+(k<<48));
- return t1*w;
+ w *= t1;
+ math_check_force_underflow_nonneg (w);
+ return w;
} else return w;
}