octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: test failure for mappers.cc


From: John W. Eaton
Subject: Re: test failure for mappers.cc
Date: Wed, 10 Nov 2010 01:23:40 -0500

On 10-Nov-2010, Ben Abbott wrote:

| If you (anyone?) can tell me which library is responsible I'll take
| a look at Apple's changes to the gcc sources. If I can find the
| place to go, I'll file a bug report as well.

The atan2f function should be in libm.  What happens if you compile
and run the following C program on your system?  I see the following
results on mine:

  M_PI = 3.141592741012573
  (float) M_PI = 3.1415927 (0x40490fdb)
  atan2f (0.0f, -1.0f) = 3.14159274 (0x40490fdb)
  atan2f (0.0f, -1.0f) - (float) M_PI = 0.00000000 (0x00000000)

But it looks like there are special cases in the libc atan2 function
(in the file sysdeps/ieee754/flt-32/e_atan2f.c):

  tiny  = 1.0e-30,
  ...
  pi      = 3.1415927410e+00,  /* 0x40490fdb */
  ...
      /* when y = 0 */
          if(iy==0) {
              switch(m) {
                  case 0:
                  case 1: return y;       /* atan(+-0,+anything)=+-0 */
                  case 2: return  pi+tiny;/* atan(+0,-anything) = pi */
                  case 3: return -pi-tiny;/* atan(-0,-anything) =-pi */
              }
          }

Both tiny and pi are declared as float in this function.

jwe

#include <math.h>
#include <stdio.h>

void
printme (const char *fmt, float f)
{
  union
  {
    float f;
    int i;
  } cvt;

  cvt.f = f;

  printf (fmt, f, cvt.i);
}

int
main (void)
{
  float pi = (float) M_PI;
  float at = atan2f (0.0f, -1.0f);
  float df = at - pi;

  printf ("M_PI = %.15f\n", pi);

  printme ("(float) M_PI = %.7f (0x%08x)\n", pi);
  printme ("atan2f (0.0f, -1.0f) = %.8f (0x%08x)\n", at);
  printme ("atan2f (0.0f, -1.0f) - (float) M_PI = %.8f (0x%08x)\n", df);

  return 0;
}

reply via email to

[Prev in Thread] Current Thread [Next in Thread]