]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/ieee754/dbl-64/slowexp.c
Update.
[thirdparty/glibc.git] / sysdeps / ieee754 / dbl-64 / slowexp.c
CommitLineData
e4d82761
UD
1/*
2 * IBM Accurate Mathematical Library
3 * Copyright (c) International Business Machines Corp., 2001
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published by
50944bca 7 * the Free Software Foundation; either version 2 of the License, or
e4d82761 8 * (at your option) any later version.
50944bca 9 *
e4d82761
UD
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program; if not, write to the Free Software
50944bca 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
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"
15b3c029 31#include "math_private.h"
e4d82761 32
ca58f1db 33void __mpexp(mp_no *x, mp_no *y, int p);
e4d82761
UD
34
35/*Converting from double precision to Multi-precision and calculating e^x */
ca58f1db 36double __slowexp(double x) {
50944bca
UD
37 double w,z,res,eps=3.0e-26;
38#if 0
39 double y;
40#endif
41 int p;
42#if 0
43 int orig,i;
44#endif
e4d82761 45 mp_no mpx, mpy, mpz,mpw,mpeps,mpcor;
50944bca 46
e4d82761 47 p=6;
ca58f1db 48 __dbl_mp(x,&mpx,p); /* Convert a double precision number x */
e4d82761 49 /* into a multiple precision number mpx with prec. p. */
ca58f1db
UD
50 __mpexp(&mpx, &mpy, p); /* Multi-Precision exponential function */
51 __dbl_mp(eps,&mpeps,p);
52 __mul(&mpeps,&mpy,&mpcor,p);
53 __add(&mpy,&mpcor,&mpw,p);
54 __sub(&mpy,&mpcor,&mpz,p);
50944bca
UD
55 __mp_dbl(&mpw, &w, p);
56 __mp_dbl(&mpz, &z, p);
e4d82761
UD
57 if (w == z) return w;
58 else { /* if calculating is not exactly */
59 p = 32;
ca58f1db
UD
60 __dbl_mp(x,&mpx,p);
61 __mpexp(&mpx, &mpy, p);
50944bca 62 __mp_dbl(&mpy, &res, p);
e4d82761
UD
63 return res;
64 }
65}