]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix spurious underflows in ldbl-128 atan implementation.
authorDavid S. Miller <davem@davemloft.net>
Mon, 19 Nov 2012 23:26:52 +0000 (15:26 -0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 19 Nov 2012 23:31:24 +0000 (15:31 -0800)
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.

ChangeLog
math/libm-test.inc
sysdeps/ieee754/ldbl-128/s_atanl.c
sysdeps/sparc/fpu/libm-test-ulps
sysdeps/x86_64/fpu/libm-test-ulps

index f2e166b2e268b2aaf56026b34d6c2dae2751e9de..7e85f770162027b29fcbd9afd76a3881ec4ebb7b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2012-11-19  David S. Miller  <davem@davemloft.net>
+
+       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.
+
 2012-11-19  Joseph Myers  <joseph@codesourcery.com>
 
        [BZ #14856]
index 0b254e1738de673b005214783ac60df72c49022a..2a60557fd9a99674d75d9843a373320e27aaf9e4 100644 (file)
@@ -1187,6 +1187,8 @@ atan_test (void)
   TEST_f_f (atan, plus_infty, M_PI_2l);
   TEST_f_f (atan, minus_infty, -M_PI_2l);
   TEST_f_f (atan, nan_value, nan_value);
+  TEST_f_f (atan, max_value, M_PI_2l);
+  TEST_f_f (atan, -max_value, -M_PI_2l);
 
   TEST_f_f (atan, 1, M_PI_4l);
   TEST_f_f (atan, -1, -M_PI_4l);
@@ -1295,6 +1297,9 @@ atan2_test (void)
 
   TEST_ff_f (atan2, max_value, max_value, M_PI_4l);
 
+  TEST_ff_f (atan2, max_value, min_value, M_PI_2l);
+  TEST_ff_f (atan2, -max_value, -min_value, -M_PI_2l);
+
   TEST_ff_f (atan2, 0.75L, 1, 0.643501108793284386802809228717322638L);
   TEST_ff_f (atan2, -0.75L, 1.0L, -0.643501108793284386802809228717322638L);
   TEST_ff_f (atan2, 0.75L, -1.0L, 2.49809154479650885165983415456218025L);
index 0138e792aaab48b2c94c628233b13c88f5da29a3..adac0a79e7108747aa3604f503a5fce9e22a668c 100644 (file)
@@ -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;
 
index ec0ad66204ee67695b1f8b089c13a92c52484171..432e01181aefe9c9d55b2a343fe3b46c956b7ad8 100644 (file)
@@ -102,6 +102,9 @@ float: 1
 ifloat: 1
 ildouble: 1
 ldouble: 1
+Test "atan2 (-max_value, -min_value) == -pi/2":
+float: 1
+ifloat: 1
 Test "atan2 (0.75, -1.0) == 2.49809154479650885165983415456218025":
 float: 1
 ifloat: 1
index 4767be94db0e01c9a0e91a58885c5e50621ca141..f33dfed3dfd3630e182eb63937b25b742429dfd3 100644 (file)
@@ -162,6 +162,9 @@ ldouble: 1
 Test "atan2 (-0.75, -1.0) == -2.49809154479650885165983415456218025":
 float: 1
 ifloat: 1
+Test "atan2 (-max_value, -min_value) == -pi/2":
+float: 1
+ifloat: 1
 Test "atan2 (0.75, -1.0) == 2.49809154479650885165983415456218025":
 float: 1
 ifloat: 1