summaryrefslogtreecommitdiff
path: root/get_str.c
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2005-01-20 11:23:51 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2005-01-20 11:23:51 +0000
commit524f117b8c0eb468e995c43778a659cb9af05ddf (patch)
tree932bdf227b3851d2c1e1ec7ce81ad2dbd01922c0 /get_str.c
parent4dd397dd7b685dc48b6c4fea81c2fdc090f92915 (diff)
downloadmpfr-524f117b8c0eb468e995c43778a659cb9af05ddf.tar.gz
fixed problems in get_str for huge exponent
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@3194 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'get_str.c')
-rw-r--r--get_str.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/get_str.c b/get_str.c
index 13c3fc37d..b362bb3ad 100644
--- a/get_str.c
+++ b/get_str.c
@@ -376,14 +376,22 @@ mpfr_get_str_aux (char *const str, mp_exp_t *const exp, mp_limb_t *const r,
static mp_exp_t
mpfr_get_str_compute_g (int beta, mp_exp_t e)
{
- double g0, g1;
+ double g0, g1, de;
mp_exp_t g;
- g0 = (double) e * log_b2[beta - 2];
- g1 = (double) e * log_b2_low[beta - 2];
+ de = (double) e;
+ g0 = de * log_b2[beta - 2];
+ g1 = de * log_b2_low[beta - 2];
+ if (de > 9007199254740992.0 || de < -9007199254740992.0)
+ /* can happen on 64-bit machines */
+ {
+ mp_exp_t low_e = e - (mp_exp_t) de;
+ g1 += (double) low_e * log_b2[beta - 2];
+ }
g = (mp_exp_t) mpfr_ceil_double (g0);
g0 -= (double) g;
- return g + (mp_exp_t) mpfr_ceil_double (g0 + g1);
+ g += (mp_exp_t) mpfr_ceil_double (g0 + g1);
+ return g;
}
/* prints the mantissa of x in the string s, and writes the corresponding