mirror of
https://github.com/vale981/arb
synced 2025-03-04 17:01:40 -05:00
catch overflow when converting to mpfr
This commit is contained in:
parent
0847d21f66
commit
849e713207
1 changed files with 11 additions and 0 deletions
11
fmpr.h
11
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;
|
||||
|
|
Loading…
Add table
Reference in a new issue