summaryrefslogtreecommitdiff
path: root/set_str.c
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2004-04-07 14:19:44 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2004-04-07 14:19:44 +0000
commitc44bde008cebc99a76205f1329ac86fef8cf65c3 (patch)
tree86ed9bfe64d93338368f8b9e9f7c735cfec520c9 /set_str.c
parenta7ed08d70837deee7ccb01c30e43efbba292f9f3 (diff)
downloadmpfr-c44bde008cebc99a76205f1329ac86fef8cf65c3.tar.gz
fixed problem when overflow in destination exponent happens
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2862 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'set_str.c')
-rw-r--r--set_str.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/set_str.c b/set_str.c
index d99733791..0c574770e 100644
--- a/set_str.c
+++ b/set_str.c
@@ -269,6 +269,11 @@ mpfr_set_str (mpfr_t x, const char *str, int base, mp_rnd_t rnd)
/* z is allocated at y - n */
z = y - n;
err = mpfr_mpn_exp (z, &exp_z, base, exp_s - (mp_exp_t) pr, n);
+ if (err == -2) /* overflow in exp_z, return Inf */
+ {
+ exp_y = __mpfr_emax;
+ goto free;
+ }
exact = (exact && (err == -1));
/* multiply(y = 0.mant_s[0]...mant_s[pr-1])_base by base^(exp_s-g) */
@@ -363,6 +368,7 @@ mpfr_set_str (mpfr_t x, const char *str, int base, mp_rnd_t rnd)
exp_y ++;
}
+ free:
TMP_FREE(marker);
/* Set sign of x before exp since check_range needs a valid sign */
@@ -372,7 +378,7 @@ mpfr_set_str (mpfr_t x, const char *str, int base, mp_rnd_t rnd)
MPFR_SET_POS(x);
/* DO NOT USE MPFR_SET_EXP. The exp may be out of range! */
MPFR_EXP (x) = exp_y + n * BITS_PER_MP_LIMB;
- res = mpfr_check_range (x, res, rnd );
+ res = mpfr_check_range (x, res, rnd);
end:
(*__gmp_free_func) (str1, size_str1 * sizeof (char));