summaryrefslogtreecommitdiff
path: root/libc/sysdeps/ieee754/dbl-64/slowexp.c
diff options
context:
space:
mode:
authorjoseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d>2013-03-03 17:10:55 +0000
committerjoseph <joseph@7b3dc134-2b1b-0410-93df-9e9f96275f8d>2013-03-03 17:10:55 +0000
commitd15f124ff59606604c0243ee19cd67bc99ecd09f (patch)
treef0b18e431b15b797d5f5dc980928cd1a26b8f74a /libc/sysdeps/ieee754/dbl-64/slowexp.c
parentc1078e9067234e88d5c1ca8af18ae67b64141d66 (diff)
downloadeglibc2-d15f124ff59606604c0243ee19cd67bc99ecd09f.tar.gz
Merge changes between r22241 and r22552 from /fsf/trunk.
git-svn-id: svn://svn.eglibc.org/trunk@22553 7b3dc134-2b1b-0410-93df-9e9f96275f8d
Diffstat (limited to 'libc/sysdeps/ieee754/dbl-64/slowexp.c')
-rw-r--r--libc/sysdeps/ieee754/dbl-64/slowexp.c54
1 files changed, 26 insertions, 28 deletions
diff --git a/libc/sysdeps/ieee754/dbl-64/slowexp.c b/libc/sysdeps/ieee754/dbl-64/slowexp.c
index 34ca3275e..c423fc311 100644
--- a/libc/sysdeps/ieee754/dbl-64/slowexp.c
+++ b/libc/sysdeps/ieee754/dbl-64/slowexp.c
@@ -34,38 +34,36 @@
# define SECTION
#endif
-void __mpexp(mp_no *x, mp_no *y, int p);
+void __mpexp (mp_no *x, mp_no *y, int p);
/*Converting from double precision to Multi-precision and calculating e^x */
double
SECTION
-__slowexp(double x) {
- double w,z,res,eps=3.0e-26;
-#if 0
- double y;
-#endif
+__slowexp (double x)
+{
+ double w, z, res, eps = 3.0e-26;
int p;
-#if 0
- int orig,i;
-#endif
- mp_no mpx, mpy, mpz,mpw,mpeps,mpcor;
+ mp_no mpx, mpy, mpz, mpw, mpeps, mpcor;
- p=6;
- __dbl_mp(x,&mpx,p); /* Convert a double precision number x */
- /* into a multiple precision number mpx with prec. p. */
- __mpexp(&mpx, &mpy, p); /* Multi-Precision exponential function */
- __dbl_mp(eps,&mpeps,p);
- __mul(&mpeps,&mpy,&mpcor,p);
- __add(&mpy,&mpcor,&mpw,p);
- __sub(&mpy,&mpcor,&mpz,p);
- __mp_dbl(&mpw, &w, p);
- __mp_dbl(&mpz, &z, p);
- if (w == z) return w;
- else { /* if calculating is not exactly */
- p = 32;
- __dbl_mp(x,&mpx,p);
- __mpexp(&mpx, &mpy, p);
- __mp_dbl(&mpy, &res, p);
- return res;
- }
+ /* Use the multiple precision __MPEXP function to compute the exponential
+ First at 144 bits and if it is not accurate enough, at 768 bits. */
+ p = 6;
+ __dbl_mp (x, &mpx, p);
+ __mpexp (&mpx, &mpy, p);
+ __dbl_mp (eps, &mpeps, p);
+ __mul (&mpeps, &mpy, &mpcor, p);
+ __add (&mpy, &mpcor, &mpw, p);
+ __sub (&mpy, &mpcor, &mpz, p);
+ __mp_dbl (&mpw, &w, p);
+ __mp_dbl (&mpz, &z, p);
+ if (w == z)
+ return w;
+ else
+ {
+ p = 32;
+ __dbl_mp (x, &mpx, p);
+ __mpexp (&mpx, &mpy, p);
+ __mp_dbl (&mpy, &res, p);
+ return res;
+ }
}