diff options
author | David S. Miller <davem@davemloft.net> | 2012-11-19 15:26:52 -0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-11-19 15:31:24 -0800 |
commit | 6d33cc9d9bde501e0906c42ee396d42cb4ca603c (patch) | |
tree | fa106d1ac0b43e69180ba0e497321d56210d4a92 /sysdeps/ieee754/ldbl-128 | |
parent | 877f2d8e8def5a278e4b9f4e4dc378f7f8a653b8 (diff) | |
download | glibc-6d33cc9d9bde501e0906c42ee396d42cb4ca603c.tar.gz glibc-6d33cc9d9bde501e0906c42ee396d42cb4ca603c.tar.xz glibc-6d33cc9d9bde501e0906c42ee396d42cb4ca603c.zip |
Fix spurious underflows in ldbl-128 atan implementation.
With help from Joseph Myers. * sysdeps/ieee754/ldbl-128/s_atanl.c (__atanl): Handle tiny and very large arguments properly. * math/libm-test.inc (atan_test): New tests. (atan2_test): New tests. * sysdeps/sparc/fpu/libm-test-ulps: Update. * sysdeps/x86_64/fpu/libm-test-ulps: Update.
Diffstat (limited to 'sysdeps/ieee754/ldbl-128')
-rw-r--r-- | sysdeps/ieee754/ldbl-128/s_atanl.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/sysdeps/ieee754/ldbl-128/s_atanl.c b/sysdeps/ieee754/ldbl-128/s_atanl.c index 0138e792aa..adac0a79e7 100644 --- a/sysdeps/ieee754/ldbl-128/s_atanl.c +++ b/sysdeps/ieee754/ldbl-128/s_atanl.c @@ -167,6 +167,7 @@ static const long double q4 = 2.173623741810414221251136181221172551416E1L; /* q5 = 1.000000000000000000000000000000000000000E0 */ +static const long double huge = 1.0e4930L; long double __atanl (long double x) @@ -197,6 +198,22 @@ __atanl (long double 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; |