summaryrefslogtreecommitdiff
path: root/set_d.c
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2001-01-19 09:55:11 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2001-01-19 09:55:11 +0000
commite6ecdf4eaa198130af30477e829a04699a445c58 (patch)
treeaa20df6d9f88875f306099d9741b21e6037288b7 /set_d.c
parentb05db5541b5eec03b06cc8e8be0639519c1bcf17 (diff)
downloadmpfr-e6ecdf4eaa198130af30477e829a04699a445c58.tar.gz
fixed pb in mpfr_get_d2 for 64-bit machines: in q + res/MP_BASE_AS_DOUBLE,
q seems first to be cast into a double, which gives more than one ulp of error git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@983 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'set_d.c')
-rw-r--r--set_d.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/set_d.c b/set_d.c
index fe8006aae..7d77f5bfd 100644
--- a/set_d.c
+++ b/set_d.c
@@ -338,9 +338,19 @@ mpfr_get_d2(src, e)
/* Accumulate the limbs from less significant to most significant
otherwise due to rounding we may accumulate several ulps,
especially in rounding towards -/+infinity. */
- for (i = n_limbs_to_use; i>=1; i--)
+ for (i = n_limbs_to_use; i>=1; i--) {
+#if (BITS_PER_MP_LIMB == 32)
res = res / MP_BASE_AS_DOUBLE +
((negative) ? -(double)qp[size - i] : qp[size - i]);
+#else
+#if (BITS_PER_MP_LIMB == 64)
+ q = qp[size - i] & (mp_limb_t) 4294967295;
+ res = res / MP_BASE_AS_DOUBLE + ((negative) ? -(double)q : q);
+ q = qp[size - i] - q;
+ res = res + ((negative) ? -(double)q : q);
+#endif /* BITS_PER_MP_LIMB == 64 */
+#endif /* BITS_PER_MP_LIMB == 32 */
+ }
res = __mpfr_scale2 (res, e - BITS_PER_MP_LIMB);
return res;