diff --git a/fmpr.h b/fmpr.h index 124b7fe7..ad2649d2 100644 --- a/fmpr.h +++ b/fmpr.h @@ -227,12 +227,23 @@ fmpr_get_mpfr(mpfr_t x, const fmpr_t y, mpfr_rnd_t rnd) else mpfr_set_nan(x); r = 0; } + else if (COEFF_IS_MPZ(*fmpr_expref(y))) + { + printf("exception: exponent too large to convert to mpfr"); + abort(); + } else { if (!COEFF_IS_MPZ(*fmpr_manref(y))) r = mpfr_set_si_2exp(x, *fmpr_manref(y), *fmpr_expref(y), rnd); else r = mpfr_set_z_2exp(x, COEFF_TO_PTR(*fmpr_manref(y)), *fmpr_expref(y), rnd); + + if (!mpfr_regular_p(x)) + { + printf("exception: exponent too large to convert to mpfr"); + abort(); + } } return r;