summaryrefslogtreecommitdiff
path: root/libquadmath/math/atanq.c
diff options
context:
space:
mode:
authorburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>2012-11-21 23:55:29 +0000
committerburnus <burnus@138bc75d-0d04-0410-961f-82ee72b054a4>2012-11-21 23:55:29 +0000
commit89a213c97ad0237409d3faf3ba320b981a397dad (patch)
treefc57edee06bfb00a7b2b91c9ea11ef86e3c7eec7 /libquadmath/math/atanq.c
parent43a0447f85401374b9f7a1370c496a06e7bb03e1 (diff)
downloadgcc-89a213c97ad0237409d3faf3ba320b981a397dad.tar.gz
2012-11-22 David S. Miller <davem@davemloft.net>
Tobias Burnus <burnus@net-b.de> Joseph Myers <joseph@codesourcery.com> * math/atanq.c (atanq): Update from GLIBC. Handle tiny and very large arguments properly. * math/j0q.c (y0q): Update from GLIBC. Avoid arithmetic underflow when 'x' is very small. * math/j1q.c (y1q): Ditto. * math/log1pq.c (log1pq): Update from GLIBC. Saturate nonzero exponents with absolute value below 0x1p-128 to +/- 0x1p-128. * math/powq.c (powq): Update from GLIBC. If xm1 is smaller than LDBL_EPSILON/2.0L, just return xm1. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@193716 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libquadmath/math/atanq.c')
-rw-r--r--libquadmath/math/atanq.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/libquadmath/math/atanq.c b/libquadmath/math/atanq.c
index cb38a340a20..8eccdc3317d 100644
--- a/libquadmath/math/atanq.c
+++ b/libquadmath/math/atanq.c
@@ -167,6 +167,7 @@ static const __float128
q4 = 2.173623741810414221251136181221172551416E1Q;
/* q5 = 1.000000000000000000000000000000000000000E0 */
+static const long double huge = 1.0e4930Q;
__float128
atanq (__float128 x)
@@ -197,6 +198,22 @@ atanq (__float128 x)
return atantbl[83];
}
+ if (k <= 0x3fc50000) /* |x| < 2**-58 */
+ {
+ /* Raise inexact. */
+ if (huge + x > 0.0)
+ return x;
+ }
+
+ if (k >= 0x40720000) /* |x| > 2**115 */
+ {
+ /* Saturate result to {-,+}pi/2 */
+ if (sign)
+ return -atantbl[83];
+ else
+ return atantbl[83];
+ }
+
if (sign)
x = -x;