Back to index

glibc  2.9
Functions | Variables
e_atan2l.c File Reference
#include "math.h"
#include "math_private.h"

Go to the source code of this file.

Functions

long double __ieee754_atan2l (long double y, long double x)

Variables

static long double tiny = 1.0e-4900L
static long double zero = 0.0
static long double pi_o_4 = 7.85398163397448309628202E-01L
static long double pi_o_2 = 1.5707963267948966192564E+00L
static long double pi = 3.14159265358979323851281E+00L
static long double pi_lo = -5.01655761266833202345176e-20L

Function Documentation

long double __ieee754_atan2l ( long double  y,
long double  x 
)

Definition at line 66 of file e_atan2l.c.

{
       long double z;
       int32_t k,m,hx,hy,ix,iy;
       u_int32_t sx,sy,lx,ly;

       GET_LDOUBLE_WORDS(sx,hx,lx,x);
       ix = sx&0x7fff;
       lx |= hx & 0x7fffffff;
       GET_LDOUBLE_WORDS(sy,hy,ly,y);
       iy = sy&0x7fff;
       ly |= hy & 0x7fffffff;
       if(((2*ix|((lx|-lx)>>31))>0xfffe)||
          ((2*iy|((ly|-ly)>>31))>0xfffe)) /* x or y is NaN */
          return x+y;
       if(((sx-0x3fff)|lx)==0) return __atanl(y);   /* x=1.0 */
       m = ((sy>>15)&1)|((sx>>14)&2);     /* 2*sign(x)+sign(y) */

    /* when y = 0 */
       if((iy|ly)==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 */
           }
       }
    /* when x = 0 */
       if((ix|lx)==0) return (sy>=0x8000)?  -pi_o_2-tiny: pi_o_2+tiny;

    /* when x is INF */
       if(ix==0x7fff) {
           if(iy==0x7fff) {
              switch(m) {
                  case 0: return  pi_o_4+tiny;/* atan(+INF,+INF) */
                  case 1: return -pi_o_4-tiny;/* atan(-INF,+INF) */
                  case 2: return  3.0*pi_o_4+tiny;/*atan(+INF,-INF)*/
                  case 3: return -3.0*pi_o_4-tiny;/*atan(-INF,-INF)*/
              }
           } else {
              switch(m) {
                  case 0: return  zero  ; /* atan(+...,+INF) */
                  case 1: return -zero  ; /* atan(-...,+INF) */
                  case 2: return  pi+tiny  ;     /* atan(+...,-INF) */
                  case 3: return -pi-tiny  ;     /* atan(-...,-INF) */
              }
           }
       }
    /* when y is INF */
       if(iy==0x7fff) return (sy>=0x8000)? -pi_o_2-tiny: pi_o_2+tiny;

    /* compute y/x */
       k = sy-sx;
       if(k > 70) z=pi_o_2+0.5*pi_lo;     /* |y/x| >  2**70 */
       else if(sx>=0x8000&&k<-70) z=0.0;  /* |y|/x < -2**70 */
       else z=__atanl(fabsl(y/x)); /* safe to do y/x */
       switch (m) {
           case 0: return       z  ;      /* atan(+,+) */
           case 1: {
                    u_int32_t sz;
                    GET_LDOUBLE_EXP(sz,z);
                    SET_LDOUBLE_EXP(z,sz ^ 0x8000);
                  }
                  return       z  ;       /* atan(-,+) */
           case 2: return  pi-(z-pi_lo);/* atan(+,-) */
           default: /* case 3 */
                  return  (z-pi_lo)-pi;/* atan(-,-) */
       }
}

Here is the call graph for this function:


Variable Documentation

long double pi = 3.14159265358979323851281E+00L [static]

Definition at line 60 of file e_atan2l.c.

long double pi_lo = -5.01655761266833202345176e-20L [static]

Definition at line 61 of file e_atan2l.c.

long double pi_o_2 = 1.5707963267948966192564E+00L [static]

Definition at line 59 of file e_atan2l.c.

long double pi_o_4 = 7.85398163397448309628202E-01L [static]

Definition at line 58 of file e_atan2l.c.

long double tiny = 1.0e-4900L [static]

Definition at line 56 of file e_atan2l.c.

long double zero = 0.0 [static]

Definition at line 57 of file e_atan2l.c.