This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: pi/2 again...


On Thu, 2 May 2013, David Miller wrote:

> This must be related to the pi/2 stuff we were discussing the other
> week.  Can someone give me some direction on how to go about fixing
> this?  I forgot where we left off in that thread.

pi/2 rounded to nearest for ldbl-128 is 
0x1.921fb54442d18469898cc51701b8p+0L (computed with MPFR).  The cosine of 
that value, again rounded to nearest, is 
0x3.9a252049c1114cf98e804177d4c8p-116L.

That cosine is exactly the value currently expected in libm-test.inc (but 
MPFR prefers a different exponent when displaying it).  If M_PI_2l, shown 
as a hex float, is equal to the value given above, then you have a problem 
with the ldbl-128 cos function being inaccurate near pi/2 (maybe a range 
reduction issue) - which will need filing as such in Bugzilla and fixing.  
If M_PI_2l is different, either there's something wrong with its value or 
a GCC bug converting the decimal value to a target long double (in either 
case, again, a user-visible bug to file in the appropriate Bugzilla and 
fix).

Program using MPFR to compute the above:

#include <stdio.h>
#include <mpfr.h>

int
main (void)
{
  mpfr_t pi2, cospi2;
  mpfr_init2 (pi2, 113);
  mpfr_init2 (cospi2, 113);
  mpfr_const_pi (pi2, MPFR_RNDN);
  mpfr_div_ui (pi2, pi2, 2, MPFR_RNDN);
  mpfr_cos (cospi2, pi2, MPFR_RNDN);
  mpfr_printf ("%Ra %Ra\n", pi2, cospi2);
  return 0;
}

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]