]> sourceware.org Git - glibc.git/blob - sysdeps/powerpc/powerpc32/power4/fpu/slowexp.c
Add script to update copyright notices and reformat some to facilitate its use.
[glibc.git] / sysdeps / powerpc / powerpc32 / power4 / fpu / slowexp.c
1 /*
2 * IBM Accurate Mathematical Library
3 * written by International Business Machines Corp.
4 * Copyright (C) 2001-2012 Free Software Foundation, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
18 */
19 /**************************************************************************/
20 /* MODULE_NAME:slowexp.c */
21 /* */
22 /* FUNCTION:slowexp */
23 /* */
24 /* FILES NEEDED:mpa.h */
25 /* mpa.c mpexp.c */
26 /* */
27 /*Converting from double precision to Multi-precision and calculating */
28 /* e^x */
29 /**************************************************************************/
30 #include <math_private.h>
31
32 #ifdef NO_LONG_DOUBLE
33 #include "mpa.h"
34 void __mpexp(mp_no *x, mp_no *y, int p);
35 #endif
36
37 /*Converting from double precision to Multi-precision and calculating e^x */
38 double __slowexp(double x) {
39 #ifdef NO_LONG_DOUBLE
40 double w,z,res,eps=3.0e-26;
41 int p;
42 mp_no mpx, mpy, mpz,mpw,mpeps,mpcor;
43
44 p=6;
45 __dbl_mp(x,&mpx,p); /* Convert a double precision number x */
46 /* into a multiple precision number mpx with prec. p. */
47 __mpexp(&mpx, &mpy, p); /* Multi-Precision exponential function */
48 __dbl_mp(eps,&mpeps,p);
49 __mul(&mpeps,&mpy,&mpcor,p);
50 __add(&mpy,&mpcor,&mpw,p);
51 __sub(&mpy,&mpcor,&mpz,p);
52 __mp_dbl(&mpw, &w, p);
53 __mp_dbl(&mpz, &z, p);
54 if (w == z) return w;
55 else { /* if calculating is not exactly */
56 p = 32;
57 __dbl_mp(x,&mpx,p);
58 __mpexp(&mpx, &mpy, p);
59 __mp_dbl(&mpy, &res, p);
60 return res;
61 }
62 #else
63 return (double) __ieee754_expl((long double)x);
64 #endif
65 }
This page took 0.046461 seconds and 6 git commands to generate.