From 98c48fe5cc4317123a168490a8fb37540e23f104 Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Thu, 21 Mar 2013 13:57:21 +0000 Subject: Fix Bessel function spurious overflows for ldbl-128 / ldbl-128ibm (bug 15285). --- sysdeps/ieee754/ldbl-128/e_j0l.c | 27 +++++++++++++++++---------- sysdeps/ieee754/ldbl-128/e_j1l.c | 27 +++++++++++++++++---------- 2 files changed, 34 insertions(+), 20 deletions(-) (limited to 'sysdeps/ieee754') diff --git a/sysdeps/ieee754/ldbl-128/e_j0l.c b/sysdeps/ieee754/ldbl-128/e_j0l.c index 9e7880c49d..108eff4435 100644 --- a/sysdeps/ieee754/ldbl-128/e_j0l.c +++ b/sysdeps/ieee754/ldbl-128/e_j0l.c @@ -93,6 +93,7 @@ #include #include +#include /* 1 / sqrt(pi) */ static const long double ONEOSQPI = 5.6418958354775628694807945156077258584405E-1L; @@ -710,11 +711,14 @@ __ieee754_j0l (long double x) __sincosl (xx, &s, &c); ss = s - c; cc = s + c; - z = -__cosl (xx + xx); - if ((s * c) < 0) - cc = z / ss; - else - ss = z / cc; + if (xx <= LDBL_MAX / 2.0L) + { + z = -__cosl (xx + xx); + if ((s * c) < 0) + cc = z / ss; + else + ss = z / cc; + } if (xx > 0x1p256L) return ONEOSQPI * cc / __ieee754_sqrtl (xx); @@ -857,11 +861,14 @@ long double __sincosl (x, &s, &c); ss = s - c; cc = s + c; - z = -__cosl (x + x); - if ((s * c) < 0) - cc = z / ss; - else - ss = z / cc; + if (xx <= LDBL_MAX / 2.0L) + { + z = -__cosl (x + x); + if ((s * c) < 0) + cc = z / ss; + else + ss = z / cc; + } if (xx > 0x1p256L) return ONEOSQPI * ss / __ieee754_sqrtl (x); diff --git a/sysdeps/ieee754/ldbl-128/e_j1l.c b/sysdeps/ieee754/ldbl-128/e_j1l.c index 95e01a39cc..70a1c86fd2 100644 --- a/sysdeps/ieee754/ldbl-128/e_j1l.c +++ b/sysdeps/ieee754/ldbl-128/e_j1l.c @@ -97,6 +97,7 @@ #include #include +#include /* 1 / sqrt(pi) */ static const long double ONEOSQPI = 5.6418958354775628694807945156077258584405E-1L; @@ -715,11 +716,14 @@ __ieee754_j1l (long double x) __sincosl (xx, &s, &c); ss = -s - c; cc = s - c; - z = __cosl (xx + xx); - if ((s * c) > 0) - cc = z / ss; - else - ss = z / cc; + if (xx <= LDBL_MAX / 2.0L) + { + z = __cosl (xx + xx); + if ((s * c) > 0) + cc = z / ss; + else + ss = z / cc; + } if (xx > 0x1p256L) { @@ -868,11 +872,14 @@ __ieee754_y1l (long double x) __sincosl (xx, &s, &c); ss = -s - c; cc = s - c; - z = __cosl (xx + xx); - if ((s * c) > 0) - cc = z / ss; - else - ss = z / cc; + if (xx <= LDBL_MAX / 2.0L) + { + z = __cosl (xx + xx); + if ((s * c) > 0) + cc = z / ss; + else + ss = z / cc; + } if (xx > 0x1p256L) return ONEOSQPI * ss / __ieee754_sqrtl (xx); -- cgit v1.2.3