summaryrefslogtreecommitdiff
path: root/get_z.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2009-04-01 14:22:03 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2009-04-01 14:22:03 +0000
commit7ae8d83868d2859bade424aa3208ba73e4a4178c (patch)
treef25fcdd11cf0e1a31489ed30e4b365b5197b72e5 /get_z.c
parenta639702750213819d861f62671b3c5c03c5c36ba (diff)
downloadmpfr-7ae8d83868d2859bade424aa3208ba73e4a4178c.tar.gz
get_z.c: detect out-of-range precision (such a detection could be missed
if mpfr_exp_t > mpfr_prec_t). git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@6151 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'get_z.c')
-rw-r--r--get_z.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/get_z.c b/get_z.c
index ef21ba259..9db39a5a0 100644
--- a/get_z.c
+++ b/get_z.c
@@ -30,7 +30,9 @@ mpfr_get_z (mpz_ptr z, mpfr_srcptr f, mp_rnd_t rnd)
mp_exp_t exp = MPFR_EXP (f);
/* if exp <= 0, then |f|<1, thus |o(f)|<=1 */
- mpfr_init2 (r, (exp < (mp_exp_t) MPFR_PREC_MIN) ? MPFR_PREC_MIN : exp);
+ MPFR_ASSERTN (exp < 0 || exp <= MPFR_PREC_MAX);
+ mpfr_init2 (r, (exp < (mp_exp_t) MPFR_PREC_MIN ?
+ MPFR_PREC_MIN : (mpfr_prec_t) exp));
mpfr_rint (r, f, rnd);
MPFR_ASSERTN (MPFR_IS_FP (r) );
exp = mpfr_get_z_exp (z, r);