Back to index

glibc  2.9
Defines | Functions
e_atan2.c File Reference
#include <math.h>
#include "math_private.h"
#include "mathimpl.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define SUFF
#define float_type   double
#define CONCATX(a, b)   __CONCAT(a,b)
#define s(name)   CONCATX(name,SUFF)
#define m81(func)   __m81_u(s(func))

Functions

float_type s() __ieee754_atan2 (float_type y, float_type x)

Define Documentation

#define CONCATX (   a,
  b 
)    __CONCAT(a,b)

Definition at line 30 of file e_atan2.c.

#define float_type   double

Definition at line 27 of file e_atan2.c.

#define m81 (   func)    __m81_u(s(func))

Definition at line 32 of file e_atan2.c.

#define s (   name)    CONCATX(name,SUFF)

Definition at line 31 of file e_atan2.c.

#define SUFF

Definition at line 24 of file e_atan2.c.


Function Documentation

Definition at line 35 of file e_atan2.c.

{
  float_type pi, pi_2, z;
  unsigned long y_cond, x_cond;

  __asm ("fmovecr%.x %#0, %0" : "=f" (pi));
  __asm ("fscale%.w %#-1, %0" : "=f" (pi_2) : "0" (pi));
  y_cond = __m81_test (y);
  x_cond = __m81_test (x);

  if ((x_cond | y_cond) & __M81_COND_NAN)
    z = x + y;
  else if (y_cond & __M81_COND_ZERO)
    {
      if (x_cond & __M81_COND_NEG)
       z = y_cond & __M81_COND_NEG ? -pi : pi;
      else
       z = y;
    }
  else if (x_cond & __M81_COND_INF)
    {
      if (y_cond & __M81_COND_INF)
       {
         float_type pi_4;
         __asm ("fscale%.w %#-2, %0" : "=f" (pi_4) : "0" (pi));
         z = x_cond & __M81_COND_NEG ? 3 * pi_4 : pi_4;
       }
      else
       z = x_cond & __M81_COND_NEG ? pi : 0;
      if (y_cond & __M81_COND_NEG)
       z = -z;
    }
  else if (y_cond & __M81_COND_INF)
    z = y_cond & __M81_COND_NEG ? -pi_2 : pi_2;
  else if (x_cond & __M81_COND_NEG)
    {
      if (y_cond & __M81_COND_NEG)
       {
         if (-x > -y)
           z = -pi + m81(__atan) (y / x);
         else
           z = -pi_2 - m81(__atan) (x / y);
       }
      else
       {
         if (-x > y)
           z = pi + m81(__atan) (y / x);
         else
           z = pi_2 - m81(__atan) (x / y);
       }
    }
  else
    {
      if (y_cond & __M81_COND_NEG)
       {
         if (x > -y)
           z = m81(__atan) (y / x);
         else
           z = -pi_2 - m81(__atan) (x / y);
       }
      else
       {
         if (x > y)
           z = m81(__atan) (y / x);
         else
           z = pi_2 - m81(__atan) (x / y);
       }
    }
  return z;
}

Here is the call graph for this function: