summaryrefslogtreecommitdiff
path: root/src/get_ld.c
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2014-02-14 15:56:54 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2014-02-14 15:56:54 +0000
commit76ec8f8f46ffe84402fe478fc2aed52002511e84 (patch)
tree38b68538a0dafd1104d66ada83f91c753f4285a3 /src/get_ld.c
parent67611f24ee6a49a55436b20e2922b558c2e1a3fe (diff)
downloadmpfr-76ec8f8f46ffe84402fe478fc2aed52002511e84.tar.gz
different fixes for set_ld, get_ld and cmd_ld with double-double
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@8972 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'src/get_ld.c')
-rw-r--r--src/get_ld.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/get_ld.c b/src/get_ld.c
index 842a2bd60..e9339a958 100644
--- a/src/get_ld.c
+++ b/src/get_ld.c
@@ -131,18 +131,17 @@ mpfr_get_ld (mpfr_srcptr x, mpfr_rnd_t rnd_mode)
/* Assume double-double format (as found with the PowerPC ABI).
The generic code below isn't used because numbers with
precision > 106 would not be supported. */
+ sh = 0; /* force sh to 0 otherwise if say x = 2^1023 + 2^(-1074)
+ then after shifting mpfr_get_d (y, rnd_mode) will
+ underflow to 0 */
mpfr_init2 (y, mpfr_get_prec (x));
mpfr_init2 (z, IEEE_DBL_MANT_DIG); /* keep the precision small */
mpfr_set (y, x, rnd_mode); /* exact */
- sh = MPFR_GET_EXP (y);
- sign = MPFR_SIGN (y);
- MPFR_SET_EXP (y, 0);
- MPFR_SET_POS (y);
- s = mpfr_get_d (y, MPFR_RNDN); /* high part of y */
+ s = mpfr_get_d (x, MPFR_RNDN); /* high part of x */
mpfr_set_d (z, s, MPFR_RNDN); /* exact */
- mpfr_sub (y, y, z, MPFR_RNDN); /* exact */
+ mpfr_sub (y, x, z, MPFR_RNDN); /* exact */
/* Add the second part of y (in the correct rounding mode). */
- r = (long double) s + mpfr_get_d (y, rnd_mode);
+ r = (long double) s + (long double) mpfr_get_d (y, rnd_mode);
}
else
#endif