~ubuntu-branches/ubuntu/precise/eglibc/precise

« back to all changes in this revision

Viewing changes to sysdeps/ieee754/ldbl-128ibm/e_atan2l.c

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2011-10-04 17:48:26 UTC
  • mfrom: (216.1.23 oneiric)
  • Revision ID: package-import@ubuntu.com-20111004174826-2cyb9ewn3ucymlsx
Tags: 2.13-20ubuntu5
libc6-dev: Don't break the current {gnat,gcj}-4.4-base versons. LP: #853688.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 * Method :
18
18
 *      1. Reduce y to positive by atan2l(y,x)=-atan2l(-y,x).
19
19
 *      2. Reduce x to positive by (if x and y are unexceptional):
20
 
 *              ARG (x+iy) = arctan(y/x)           ... if x > 0,
 
20
 *              ARG (x+iy) = arctan(y/x)           ... if x > 0,
21
21
 *              ARG (x+iy) = pi - arctan[y/(-x)]   ... if x < 0,
22
22
 *
23
23
 * Special cases:
43
43
#include "math.h"
44
44
#include "math_private.h"
45
45
 
 
46
#ifdef __STDC__
46
47
static const long double
 
48
#else
 
49
static long double
 
50
#endif
47
51
tiny  = 1.0e-300L,
48
52
zero  = 0.0,
49
53
pi_o_4  = 7.85398163397448309615660845819875699e-01L, /* 3ffe921fb54442d18469898cc51701b8 */
51
55
pi      = 3.14159265358979323846264338327950280e+00L, /* 4000921fb54442d18469898cc51701b8 */
52
56
pi_lo   = 8.67181013012378102479704402604335225e-35L; /* 3f8dcd129024e088a67cc74020bbea64 */
53
57
 
54
 
long double
55
 
__ieee754_atan2l(long double y, long double x)
 
58
#ifdef __STDC__
 
59
        long double __ieee754_atan2l(long double y, long double x)
 
60
#else
 
61
        long double __ieee754_atan2l(y,x)
 
62
        long double  y,x;
 
63
#endif
56
64
{
57
65
        long double z;
58
66
        int64_t k,m,hx,hy,ix,iy;
72
80
        if((iy|(ly&0x7fffffffffffffffLL))==0) {
73
81
            switch(m) {
74
82
                case 0:
75
 
                case 1: return y;       /* atan(+-0,+anything)=+-0 */
 
83
                case 1: return y;       /* atan(+-0,+anything)=+-0 */
76
84
                case 2: return  pi+tiny;/* atan(+0,-anything) = pi */
77
85
                case 3: return -pi-tiny;/* atan(-0,-anything) =-pi */
78
86
            }
103
111
 
104
112
    /* compute y/x */
105
113
        k = (iy-ix)>>52;
106
 
        if(k > 120) z=pi_o_2+0.5L*pi_lo;        /* |y/x| >  2**120 */
107
 
        else if(hx<0&&k<-120) z=0.0L;           /* |y|/x < -2**120 */
 
114
        if(k > 120) z=pi_o_2+0.5L*pi_lo;        /* |y/x| >  2**120 */
 
115
        else if(hx<0&&k<-120) z=0.0L;           /* |y|/x < -2**120 */
108
116
        else z=__atanl(fabsl(y/x));             /* safe to do y/x */
109
117
        switch (m) {
110
118
            case 0: return       z  ;   /* atan(+,+) */
111
119
            case 1: return      -z  ;   /* atan(-,+) */
112
120
            case 2: return  pi-(z-pi_lo);/* atan(+,-) */
113
121
            default: /* case 3 */
114
 
                    return  (z-pi_lo)-pi;/* atan(-,-) */
 
122
                    return  (z-pi_lo)-pi;/* atan(-,-) */
115
123
        }
116
124
}
117
 
strong_alias (__ieee754_atan2l, __atan2l_finite)