[PATCH] fix for accuracy problem in atan2f

Jeff Johnston jjohnstn@redhat.com
Wed Jul 20 16:21:00 GMT 2005


Patch applied.  Thanks.

-- Jeff J.

Bob Wilson wrote:
> This patch fixes a problem with the accuracy of atan2f by changing to 
> use the round-to-nearest value of pi.  See 
> http://lists.freebsd.org/pipermail/cvs-all/2004-June/067012.html for a 
> better description of the issue.  A similar change was made to glibc 
> back in July 1997, but there was a typo in that change, for which I have 
> just submitted a patch: 
> http://sources.redhat.com/ml/libc-alpha/2005-07/msg00042.html.  See my 
> glibc patch if you want a testcase to demonstrate the problem.
> 
> 2005-07-20  Bob Wilson  <bob.wilson@acm.org>
>            Darin Petkov <darin@tensilica.com>
> 
>        * libm/math/ef_atan2.c (pi, pi_lo): Use round-to-nearest value of 
> pi.
> 
> 
> ------------------------------------------------------------------------
> 
> Index: libm/math/ef_atan2.c
> ===================================================================
> RCS file: /cvs/src/src/newlib/libm/math/ef_atan2.c,v
> retrieving revision 1.2
> diff -u -r1.2 ef_atan2.c
> --- libm/math/ef_atan2.c	4 Apr 2001 13:30:59 -0000	1.2
> +++ libm/math/ef_atan2.c	20 Jul 2005 15:43:14 -0000
> @@ -25,8 +25,8 @@
>  zero  = 0.0,
>  pi_o_4  = 7.8539818525e-01, /* 0x3f490fdb */
>  pi_o_2  = 1.5707963705e+00, /* 0x3fc90fdb */
> -pi      = 3.1415925026e+00, /* 0x40490fda */
> -pi_lo   = 1.5099578832e-07; /* 0x34222168 */
> +pi      = 3.1415927410e+00,  /* 0x40490fdb */
> +pi_lo   = -8.7422776573e-08; /* 0xb3bbbd2e */
>  
>  #ifdef __STDC__
>  	float __ieee754_atan2f(float y, float x)



More information about the Newlib mailing list