diff options
author | bdadoun <bdadoun@211d60ee-9f03-0410-a15a-8952a2c7a4e4> | 2012-06-27 08:34:34 +0000 |
---|---|---|
committer | bdadoun <bdadoun@211d60ee-9f03-0410-a15a-8952a2c7a4e4> | 2012-06-27 08:34:34 +0000 |
commit | 71973e26ea981b5da50baada531ec51ffe7ad46e (patch) | |
tree | 36f05f22492ae612a658b705b06a32d7a8c42956 /src | |
parent | 5a23adc7fc0f8b18c5eeb29f54ec11575f09cc03 (diff) | |
download | mpc-71973e26ea981b5da50baada531ec51ffe7ad46e.tar.gz |
[src/div.c] better handling of overflows (Benjamin Dadoun)
git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/trunk@1179 211d60ee-9f03-0410-a15a-8952a2c7a4e4
Diffstat (limited to 'src')
-rw-r--r-- | src/div.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -311,16 +311,20 @@ mpc_div (mpc_ptr a, mpc_srcptr b, mpc_srcptr c, mpc_rnd_t rnd) hopefully, the side-effects of mpc_mul do indeed raise the mpfr exceptions */ if (overflow_prod) { - if (!mpfr_zero_p (mpc_realref (res))) + mpfr_nextabove (mpc_realref (res)); + if (mpfr_inf_p (mpc_realref (res))) { mpfr_set_inf (mpc_realref (res), mpfr_sgn (mpc_realref (res))); overflow_re = 1; } - if (!mpfr_zero_p (mpc_imagref (res))) + else mpfr_nextbelow (mpc_realref (res)); + mpfr_nextabove (mpc_imagref (res)); + if (mpfr_inf_p (mpc_imagref (res))) { mpfr_set_inf (mpc_imagref (res), mpfr_sgn (mpc_imagref (res))); overflow_im = 1; } + else mpfr_nextbelow (mpc_imagref (res)); mpc_set (a, res, rnd); goto end; } |