]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/ieee754/dbl-64/slowexp.c
Add script to update copyright notices and reformat some to facilitate its use.
[thirdparty/glibc.git] / sysdeps / ieee754 / dbl-64 / slowexp.c
CommitLineData
e4d82761
UD
1/*
2 * IBM Accurate Mathematical Library
aeb25823 3 * written by International Business Machines Corp.
f4cf5f2d 4 * Copyright (C) 2001-2012 Free Software Foundation, Inc.
e4d82761
UD
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
cc7375ce 8 * the Free Software Foundation; either version 2.1 of the License, or
e4d82761 9 * (at your option) any later version.
50944bca 10 *
e4d82761
UD
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
c6c6dd48 14 * GNU Lesser General Public License for more details.
e4d82761
UD
15 *
16 * You should have received a copy of the GNU Lesser General Public License
59ba27a6 17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
e4d82761
UD
18 */
19/**************************************************************************/
20/* MODULE_NAME:slowexp.c */
21/* */
50944bca 22/* FUNCTION:slowexp */
e4d82761
UD
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 "mpa.h"
1ed0291c 31#include <math_private.h>
e4d82761 32
31d3cc00
UD
33#ifndef SECTION
34# define SECTION
35#endif
36
ca58f1db 37void __mpexp(mp_no *x, mp_no *y, int p);
e4d82761
UD
38
39/*Converting from double precision to Multi-precision and calculating e^x */
31d3cc00
UD
40double
41SECTION
42__slowexp(double x) {
50944bca
UD
43 double w,z,res,eps=3.0e-26;
44#if 0
45 double y;
46#endif
47 int p;
48#if 0
49 int orig,i;
50#endif
e4d82761 51 mp_no mpx, mpy, mpz,mpw,mpeps,mpcor;
50944bca 52
e4d82761 53 p=6;
ca58f1db 54 __dbl_mp(x,&mpx,p); /* Convert a double precision number x */
31d3cc00 55 /* into a multiple precision number mpx with prec. p. */
ca58f1db
UD
56 __mpexp(&mpx, &mpy, p); /* Multi-Precision exponential function */
57 __dbl_mp(eps,&mpeps,p);
58 __mul(&mpeps,&mpy,&mpcor,p);
59 __add(&mpy,&mpcor,&mpw,p);
60 __sub(&mpy,&mpcor,&mpz,p);
50944bca
UD
61 __mp_dbl(&mpw, &w, p);
62 __mp_dbl(&mpz, &z, p);
e4d82761
UD
63 if (w == z) return w;
64 else { /* if calculating is not exactly */
65 p = 32;
ca58f1db
UD
66 __dbl_mp(x,&mpx,p);
67 __mpexp(&mpx, &mpy, p);
50944bca 68 __mp_dbl(&mpy, &res, p);
e4d82761
UD
69 return res;
70 }
71}