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

« back to all changes in this revision

Viewing changes to sysdeps/ieee754/flt-32/e_powf.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:
13
13
 * ====================================================
14
14
 */
15
15
 
16
 
#if defined(LIBM_SCCS) && !defined(lint)
17
 
static char rcsid[] = "$NetBSD: e_powf.c,v 1.7 1996/04/08 15:43:44 phil Exp $";
18
 
#endif
19
 
 
20
16
#include "math.h"
21
17
#include "math_private.h"
22
18
 
23
19
static const float huge = 1.0e+30, tiny = 1.0e-30;
24
20
 
25
 
#ifdef __STDC__
26
21
static const float
27
 
#else
28
 
static float
29
 
#endif
30
22
bp[] = {1.0, 1.5,},
31
23
dp_h[] = { 0.0, 5.84960938e-01,}, /* 0x3f15c000 */
32
24
dp_l[] = { 0.0, 1.56322085e-06,}, /* 0x35d1cfdc */
57
49
ivln2_h  =  1.4426879883e+00, /* 0x3fb8aa00 =16b 1/ln2*/
58
50
ivln2_l  =  7.0526075433e-06; /* 0x36eca570 =1/ln2 tail*/
59
51
 
60
 
#ifdef __STDC__
61
 
        float __ieee754_powf(float x, float y)
62
 
#else
63
 
        float __ieee754_powf(x,y)
64
 
        float x, y;
65
 
#endif
 
52
float
 
53
__ieee754_powf(float x, float y)
66
54
{
67
55
        float z,ax,z_h,z_l,p_h,p_l;
68
56
        float y1,t1,t2,r,s,t,u,v,w;
81
69
        if(x == -1.0 && isinf(y)) return one;
82
70
 
83
71
    /* +-NaN return x+y */
84
 
        if(ix > 0x7f800000 ||
85
 
           iy > 0x7f800000)
 
72
        if(__builtin_expect(ix > 0x7f800000 ||
 
73
                            iy > 0x7f800000, 0))
86
74
                return x+y;
87
75
 
88
76
    /* determine if y is an odd int when x < 0
101
89
        }
102
90
 
103
91
    /* special value of y */
104
 
        if (iy==0x7f800000) {   /* y is +-inf */
 
92
        if (__builtin_expect(iy==0x7f800000, 0)) {      /* y is +-inf */
105
93
            if (ix==0x3f800000)
106
 
                return  y - y;  /* inf**+-1 is NaN */
 
94
                return  y - y;  /* inf**+-1 is NaN */
107
95
            else if (ix > 0x3f800000)/* (|x|>1)**+-inf = inf,0 */
108
 
                return (hy>=0)? y: zero;
 
96
                return (hy>=0)? y: zero;
109
97
            else                        /* (|x|<1)**-,+inf = inf,0 */
110
 
                return (hy<0)?-y: zero;
 
98
                return (hy<0)?-y: zero;
111
99
        }
112
100
        if(iy==0x3f800000) {    /* y is  +-1 */
113
101
            if(hy<0) return one/x; else return x;
114
102
        }
115
103
        if(hy==0x40000000) return x*x; /* y is  2 */
116
104
        if(hy==0x3f000000) {    /* y is  0.5 */
117
 
            if(hx>=0)   /* x >= +0 */
 
105
            if(__builtin_expect(hx>=0, 1))      /* x >= +0 */
118
106
            return __ieee754_sqrtf(x);
119
107
        }
120
108
 
121
109
        ax   = fabsf(x);
122
110
    /* special value of x */
123
 
        if(ix==0x7f800000||ix==0||ix==0x3f800000){
 
111
        if(__builtin_expect(ix==0x7f800000||ix==0||ix==0x3f800000, 0)){
124
112
            z = ax;                     /*x is +-0,+-inf,+-1*/
125
113
            if(hy<0) z = one/z; /* z = (1/|x|) */
126
114
            if(hx<0) {
133
121
        }
134
122
 
135
123
    /* (x<0)**(non-int) is NaN */
136
 
        if(((((u_int32_t)hx>>31)-1)|yisint)==0) return (x-x)/(x-x);
 
124
        if(__builtin_expect(((((u_int32_t)hx>>31)-1)|yisint)==0, 0))
 
125
            return (x-x)/(x-x);
137
126
 
138
127
    /* |y| is huge */
139
 
        if(iy>0x4d000000) { /* if |y| > 2**27 */
 
128
        if(__builtin_expect(iy>0x4d000000, 0)) { /* if |y| > 2**27 */
140
129
        /* over/underflow if x is not close to one */
141
130
            if(ix<0x3f7ffff8) return (hy<0)? huge*huge:tiny*tiny;
142
131
            if(ix>0x3f800007) return (hy>0)? huge*huge:tiny*tiny;
214
203
        p_h = y1*t1;
215
204
        z = p_l+p_h;
216
205
        GET_FLOAT_WORD(j,z);
217
 
        if (j>0x43000000)                               /* if z > 128 */
 
206
        if (__builtin_expect(j>0x43000000, 0))          /* if z > 128 */
218
207
            return s*huge*huge;                         /* overflow */
219
 
        else if (j==0x43000000) {                       /* if z == 128 */
 
208
        else if (__builtin_expect(j==0x43000000, 0)) {  /* if z == 128 */
220
209
            if(p_l+ovt>z-p_h) return s*huge*huge;       /* overflow */
221
210
        }
222
 
        else if ((j&0x7fffffff)>0x43160000)             /* z <= -150 */
 
211
        else if (__builtin_expect((j&0x7fffffff)>0x43160000, 0))/* z <= -150 */
223
212
            return s*tiny*tiny;                         /* underflow */
224
 
        else if ((u_int32_t) j==0xc3160000){            /* z == -150 */
 
213
        else if (__builtin_expect((u_int32_t) j==0xc3160000, 0)){/* z == -150*/
225
214
            if(p_l<=z-p_h) return s*tiny*tiny;          /* underflow */
226
215
        }
227
216
    /*
255
244
        else SET_FLOAT_WORD(z,j);
256
245
        return s*z;
257
246
}
 
247
strong_alias (__ieee754_powf, __powf_finite)