Skip to content

Commit

Permalink
Fix dbl-64 atan in non-default rounding modes (bug 18197).
Browse files Browse the repository at this point in the history
The dbl-64 implementation of atan does computations that expect to run
in round-to-nearest mode, and in other modes the errors can accumulate
to more than the maximum accepted 9ulp.  This patch makes it use
FE_TONEAREST internally, similar to other functions with such issues.

Tested for x86_64 and x86; no ulps updates needed.

	[BZ #18197]
	* sysdeps/ieee754/dbl-64/s_atan.c: Include <fenv.h>.
	(atan): Set FE_TONEAREST mode for internal computations.
	* math/auto-libm-test-in: Add more tests of atan.
	* math/auto-libm-test-out: Regenerated.
  • Loading branch information
Joseph Myers committed Apr 8, 2015
1 parent d5856d0 commit ae63c7e
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 1 deletion.
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
2015-04-08 Joseph Myers <joseph@codesourcery.com>

[BZ #18197]
* sysdeps/ieee754/dbl-64/s_atan.c: Include <fenv.h>.
(atan): Set FE_TONEAREST mode for internal computations.
* math/auto-libm-test-in: Add more tests of atan.
* math/auto-libm-test-out: Regenerated.

2015-04-07 James Cowgill <james410@cowgill.org.uk>

[BZ #17930]
Expand Down
2 changes: 1 addition & 1 deletion NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Version 2.22
17836, 17912, 17916, 17930, 17932, 17944, 17949, 17964, 17965, 17967,
17969, 17978, 17987, 17991, 17996, 17998, 17999, 18019, 18020, 18029,
18030, 18032, 18036, 18038, 18039, 18042, 18043, 18046, 18047, 18068,
18080, 18093, 18100, 18104, 18110, 18111, 18128, 18138, 18185.
18080, 18093, 18100, 18104, 18110, 18111, 18128, 18138, 18185, 18197.

* A powerpc and powerpc64 optimization for TLS, similar to TLS descriptors
for LD and GD on x86 and x86-64, has been implemented. You will need
Expand Down
2 changes: 2 additions & 0 deletions math/auto-libm-test-in
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ atan 1e6
atan 0x1p-100
atan 0x1p-600
atan 0x1p-10000
atan -0x3.b02d84p-4
atan -0x3.3fb708p-4
atan min
atan -min
atan min_subnorm
Expand Down
50 changes: 50 additions & 0 deletions math/auto-libm-test-out
Original file line number Diff line number Diff line change
Expand Up @@ -7877,6 +7877,56 @@ atan 0x1p-10000
= atan tonearest ldbl-128 0x1p-10000L : 0x1p-10000L : inexact-ok
= atan towardzero ldbl-128 0x1p-10000L : 0xf.fffffffffffffffffffffffffff8p-10004L : inexact-ok
= atan upward ldbl-128 0x1p-10000L : 0x1p-10000L : inexact-ok
atan -0x3.b02d84p-4
= atan downward flt-32 -0x3.b02d84p-4f : -0x3.9ff7e4p-4f : inexact-ok
= atan tonearest flt-32 -0x3.b02d84p-4f : -0x3.9ff7ep-4f : inexact-ok
= atan towardzero flt-32 -0x3.b02d84p-4f : -0x3.9ff7ep-4f : inexact-ok
= atan upward flt-32 -0x3.b02d84p-4f : -0x3.9ff7ep-4f : inexact-ok
= atan downward dbl-64 -0x3.b02d84p-4 : -0x3.9ff7e1f81370cp-4 : inexact-ok
= atan tonearest dbl-64 -0x3.b02d84p-4 : -0x3.9ff7e1f81370cp-4 : inexact-ok
= atan towardzero dbl-64 -0x3.b02d84p-4 : -0x3.9ff7e1f81370ap-4 : inexact-ok
= atan upward dbl-64 -0x3.b02d84p-4 : -0x3.9ff7e1f81370ap-4 : inexact-ok
= atan downward ldbl-96-intel -0x3.b02d84p-4L : -0x3.9ff7e1f81370b934p-4L : inexact-ok
= atan tonearest ldbl-96-intel -0x3.b02d84p-4L : -0x3.9ff7e1f81370b93p-4L : inexact-ok
= atan towardzero ldbl-96-intel -0x3.b02d84p-4L : -0x3.9ff7e1f81370b93p-4L : inexact-ok
= atan upward ldbl-96-intel -0x3.b02d84p-4L : -0x3.9ff7e1f81370b93p-4L : inexact-ok
= atan downward ldbl-96-m68k -0x3.b02d84p-4L : -0x3.9ff7e1f81370b934p-4L : inexact-ok
= atan tonearest ldbl-96-m68k -0x3.b02d84p-4L : -0x3.9ff7e1f81370b93p-4L : inexact-ok
= atan towardzero ldbl-96-m68k -0x3.b02d84p-4L : -0x3.9ff7e1f81370b93p-4L : inexact-ok
= atan upward ldbl-96-m68k -0x3.b02d84p-4L : -0x3.9ff7e1f81370b93p-4L : inexact-ok
= atan downward ldbl-128 -0x3.b02d84p-4L : -0x3.9ff7e1f81370b93195e0357d0b5ap-4L : inexact-ok
= atan tonearest ldbl-128 -0x3.b02d84p-4L : -0x3.9ff7e1f81370b93195e0357d0b5ap-4L : inexact-ok
= atan towardzero ldbl-128 -0x3.b02d84p-4L : -0x3.9ff7e1f81370b93195e0357d0b58p-4L : inexact-ok
= atan upward ldbl-128 -0x3.b02d84p-4L : -0x3.9ff7e1f81370b93195e0357d0b58p-4L : inexact-ok
= atan downward ldbl-128ibm -0x3.b02d84p-4L : -0x3.9ff7e1f81370b93195e0357d0cp-4L : inexact-ok
= atan tonearest ldbl-128ibm -0x3.b02d84p-4L : -0x3.9ff7e1f81370b93195e0357d0bp-4L : inexact-ok
= atan towardzero ldbl-128ibm -0x3.b02d84p-4L : -0x3.9ff7e1f81370b93195e0357d0bp-4L : inexact-ok
= atan upward ldbl-128ibm -0x3.b02d84p-4L : -0x3.9ff7e1f81370b93195e0357d0bp-4L : inexact-ok
atan -0x3.3fb708p-4
= atan downward flt-32 -0x3.3fb708p-4f : -0x3.348f0cp-4f : inexact-ok
= atan tonearest flt-32 -0x3.3fb708p-4f : -0x3.348f08p-4f : inexact-ok
= atan towardzero flt-32 -0x3.3fb708p-4f : -0x3.348f08p-4f : inexact-ok
= atan upward flt-32 -0x3.3fb708p-4f : -0x3.348f08p-4f : inexact-ok
= atan downward dbl-64 -0x3.3fb708p-4 : -0x3.348f092072332p-4 : inexact-ok
= atan tonearest dbl-64 -0x3.3fb708p-4 : -0x3.348f092072332p-4 : inexact-ok
= atan towardzero dbl-64 -0x3.3fb708p-4 : -0x3.348f09207233p-4 : inexact-ok
= atan upward dbl-64 -0x3.3fb708p-4 : -0x3.348f09207233p-4 : inexact-ok
= atan downward ldbl-96-intel -0x3.3fb708p-4L : -0x3.348f092072331fdcp-4L : inexact-ok
= atan tonearest ldbl-96-intel -0x3.3fb708p-4L : -0x3.348f092072331fd8p-4L : inexact-ok
= atan towardzero ldbl-96-intel -0x3.3fb708p-4L : -0x3.348f092072331fd8p-4L : inexact-ok
= atan upward ldbl-96-intel -0x3.3fb708p-4L : -0x3.348f092072331fd8p-4L : inexact-ok
= atan downward ldbl-96-m68k -0x3.3fb708p-4L : -0x3.348f092072331fdcp-4L : inexact-ok
= atan tonearest ldbl-96-m68k -0x3.3fb708p-4L : -0x3.348f092072331fd8p-4L : inexact-ok
= atan towardzero ldbl-96-m68k -0x3.3fb708p-4L : -0x3.348f092072331fd8p-4L : inexact-ok
= atan upward ldbl-96-m68k -0x3.3fb708p-4L : -0x3.348f092072331fd8p-4L : inexact-ok
= atan downward ldbl-128 -0x3.3fb708p-4L : -0x3.348f092072331fd8ca0cbff348d8p-4L : inexact-ok
= atan tonearest ldbl-128 -0x3.3fb708p-4L : -0x3.348f092072331fd8ca0cbff348d6p-4L : inexact-ok
= atan towardzero ldbl-128 -0x3.3fb708p-4L : -0x3.348f092072331fd8ca0cbff348d6p-4L : inexact-ok
= atan upward ldbl-128 -0x3.3fb708p-4L : -0x3.348f092072331fd8ca0cbff348d6p-4L : inexact-ok
= atan downward ldbl-128ibm -0x3.3fb708p-4L : -0x3.348f092072331fd8ca0cbff349p-4L : inexact-ok
= atan tonearest ldbl-128ibm -0x3.3fb708p-4L : -0x3.348f092072331fd8ca0cbff349p-4L : inexact-ok
= atan towardzero ldbl-128ibm -0x3.3fb708p-4L : -0x3.348f092072331fd8ca0cbff348p-4L : inexact-ok
= atan upward ldbl-128ibm -0x3.3fb708p-4L : -0x3.348f092072331fd8ca0cbff348p-4L : inexact-ok
atan min
= atan downward flt-32 0x4p-128f : 0x3.fffff8p-128f : inexact-ok underflow-ok errno-erange-ok
= atan tonearest flt-32 0x4p-128f : 0x4p-128f : inexact-ok underflow-ok errno-erange-ok
Expand Down
2 changes: 2 additions & 0 deletions sysdeps/ieee754/dbl-64/s_atan.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "MathLib.h"
#include "uatan.tbl"
#include "atnat.h"
#include <fenv.h>
#include <float.h>
#include <math.h>
#include <math_private.h>
Expand Down Expand Up @@ -81,6 +82,7 @@ atan (double x)
return x + x;

/* Regular values of x, including denormals +-0 and +-INF */
SET_RESTORE_ROUND (FE_TONEAREST);
u = (x < 0) ? -x : x;
if (u < C)
{
Expand Down

0 comments on commit ae63c7e

Please sign in to comment.