~ubuntu-branches/ubuntu/wily/musl/wily

« back to all changes in this revision

Viewing changes to src/math/exp2l.c

  • Committer: Package Import Robot
  • Author(s): Kevin Bortis
  • Date: 2013-09-27 23:47:18 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20130927234718-a96bgcnvzx5buf60
Tags: 0.9.14-1
* Import upstream version 0.9.14
* Only build on fully supported architectures
* Point to new homepage in control file (Closes: #724277)
* Revorked debian/rules
* Solved possible problem with postrm script (Closes: #724247)

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
        return exp2(x);
34
34
}
35
35
#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
36
 
 
37
36
#define TBLBITS 7
38
37
#define TBLSIZE (1 << TBLBITS)
39
38
 
40
 
#define BIAS    (LDBL_MAX_EXP - 1)
41
 
#define EXPMASK (BIAS + LDBL_MAX_EXP)
42
 
 
43
39
static const double
44
40
redux = 0x1.8p63 / TBLSIZE,
45
41
P1    = 0x1.62e42fefa39efp-1,
203
199
 */
204
200
long double exp2l(long double x)
205
201
{
206
 
        union IEEEl2bits u, v;
 
202
        union ldshape u = {x};
 
203
        int e = u.i.se & 0x7fff;
207
204
        long double r, z;
208
 
        uint32_t hx, ix, i0;
 
205
        uint32_t i0;
209
206
        union {uint32_t u; int32_t i;} k;
210
207
 
211
208
        /* Filter out exceptional cases. */
212
 
        u.e = x;
213
 
        hx = u.xbits.expsign;
214
 
        ix = hx & EXPMASK;
215
 
        if (ix >= BIAS + 14) {  /* |x| >= 16384 or x is NaN */
216
 
                if (ix == EXPMASK) {
217
 
                        if (u.xbits.man == 1ULL << 63 && hx == 0xffff) /* -inf */
 
209
        if (e >= 0x3fff + 13) {  /* |x| >= 8192 or x is NaN */
 
210
                if (u.i.se >= 0x3fff + 14 && u.i.se >> 15 == 0)
 
211
                        /* overflow */
 
212
                        return x * 0x1p16383L;
 
213
                if (e == 0x7fff)  /* -inf or -nan */
 
214
                        return -1/x;
 
215
                if (x < -16382) {
 
216
                        if (x <= -16446 || x - 0x1p63 + 0x1p63 != x)
 
217
                                /* underflow */
 
218
                                FORCE_EVAL((float)(-0x1p-149/x));
 
219
                        if (x <= -16446)
218
220
                                return 0;
219
 
                        return x;
220
 
                }
221
 
                if (x >= 16384) {
222
 
                        x *= 0x1p16383L;
223
 
                        return x;
224
 
                }
225
 
                if (x <= -16446)
226
 
                        return 0x1p-10000L*0x1p-10000L;
227
 
        } else if (ix < BIAS - 64)  /* |x| < 0x1p-64 */
 
221
                }
 
222
        } else if (e < 0x3fff - 64) {
228
223
                return 1 + x;
 
224
        }
229
225
 
230
226
        /*
231
227
         * Reduce x, computing z, i0, and k. The low bits of x + redux
238
234
         * We split this into k = 0xabc and i0 = 0x12 (adjusted to
239
235
         * index into the table), then we compute z = 0x0.003456p0.
240
236
         */
241
 
        u.e = x + redux;
242
 
        i0 = u.bits.manl + TBLSIZE / 2;
 
237
        u.f = x + redux;
 
238
        i0 = u.i.m + TBLSIZE / 2;
243
239
        k.u = i0 / TBLSIZE * TBLSIZE;
244
240
        k.i /= TBLSIZE;
245
241
        i0 %= TBLSIZE;
246
 
        u.e -= redux;
247
 
        z = x - u.e;
 
242
        u.f -= redux;
 
243
        z = x - u.f;
248
244
 
249
245
        /* Compute r = exp2l(y) = exp2lt[i0] * p(z). */
250
246
        long double t_hi = tbl[2*i0];