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

« back to all changes in this revision

Viewing changes to sysdeps/ieee754/ldbl-96/e_atan2l.c

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2012-02-08 01:58:09 UTC
  • mfrom: (1.5.3) (288.1.12 precise)
  • Revision ID: package-import@ubuntu.com-20120208015809-ulscst7uteq3e22z
Tags: 2.15~pre6-0ubuntu10
Merge from Debian (r5151, 2.13-26).

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
 * ====================================================
15
15
 */
16
16
 
17
 
#if defined(LIBM_SCCS) && !defined(lint)
18
 
static char rcsid[] = "$NetBSD: $";
19
 
#endif
20
 
 
21
17
/* __ieee754_atan2l(y,x)
22
18
 * Method :
23
19
 *      1. Reduce y to positive by atan2(y,x)=-atan2(-y,x).
24
20
 *      2. Reduce x to positive by (if x and y are unexceptional):
25
 
 *              ARG (x+iy) = arctan(y/x)           ... if x > 0,
 
21
 *              ARG (x+iy) = arctan(y/x)           ... if x > 0,
26
22
 *              ARG (x+iy) = pi - arctan[y/(-x)]   ... if x < 0,
27
23
 *
28
24
 * Special cases:
48
44
#include "math.h"
49
45
#include "math_private.h"
50
46
 
51
 
#ifdef __STDC__
52
47
static const long double
53
 
#else
54
 
static long double
55
 
#endif
56
48
tiny  = 1.0e-4900L,
57
49
zero  = 0.0,
58
50
pi_o_4  = 7.85398163397448309628202E-01L, /* 0x3FFE, 0xC90FDAA2, 0x2168C235 */
60
52
pi      = 3.14159265358979323851281E+00L, /* 0x4000, 0xC90FDAA2, 0x2168C235 */
61
53
pi_lo   = -5.01655761266833202345176e-20L;/* 0xBFBE, 0xECE675D1, 0xFC8F8CBB */
62
54
 
63
 
#ifdef __STDC__
64
 
        long double __ieee754_atan2l(long double y, long double x)
65
 
#else
66
 
        long double __ieee754_atan2l(y,x)
67
 
        long double  y,x;
68
 
#endif
 
55
long double
 
56
__ieee754_atan2l (long double y, long double x)
69
57
{
70
58
        long double z;
71
59
        int32_t k,m,hx,hy,ix,iy;
87
75
        if((iy|ly)==0) {
88
76
            switch(m) {
89
77
                case 0:
90
 
                case 1: return y;       /* atan(+-0,+anything)=+-0 */
 
78
                case 1: return y;       /* atan(+-0,+anything)=+-0 */
91
79
                case 2: return  pi+tiny;/* atan(+0,-anything) = pi */
92
80
                case 3: return -pi-tiny;/* atan(-0,-anything) =-pi */
93
81
            }
118
106
 
119
107
    /* compute y/x */
120
108
        k = sy-sx;
121
 
        if(k > 70) z=pi_o_2+0.5*pi_lo;  /* |y/x| >  2**70 */
122
 
        else if(sx>=0x8000&&k<-70) z=0.0;       /* |y|/x < -2**70 */
 
109
        if(k > 70) z=pi_o_2+0.5*pi_lo;  /* |y/x| >  2**70 */
 
110
        else if(sx>=0x8000&&k<-70) z=0.0;       /* |y|/x < -2**70 */
123
111
        else z=__atanl(fabsl(y/x));     /* safe to do y/x */
124
112
        switch (m) {
125
113
            case 0: return       z  ;   /* atan(+,+) */
126
114
            case 1: {
127
 
                      u_int32_t sz;
 
115
                      u_int32_t sz;
128
116
                      GET_LDOUBLE_EXP(sz,z);
129
117
                      SET_LDOUBLE_EXP(z,sz ^ 0x8000);
130
118
                    }
131
119
                    return       z  ;   /* atan(-,+) */
132
120
            case 2: return  pi-(z-pi_lo);/* atan(+,-) */
133
121
            default: /* case 3 */
134
 
                    return  (z-pi_lo)-pi;/* atan(-,-) */
 
122
                    return  (z-pi_lo)-pi;/* atan(-,-) */
135
123
        }
136
124
}
 
125
strong_alias (__ieee754_atan2l, __atan2l_finite)