summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Zimmermann <Paul.Zimmermann@inria.fr>2018-11-21 16:21:26 +0100
committerPaul Zimmermann <Paul.Zimmermann@inria.fr>2018-11-21 16:21:26 +0100
commit82df0cc40e47317217878f57acad014ea544f974 (patch)
tree279edce46d4afdc99a37d46b2129b67009ecc6a5
parent389c43dfbf14f5200ad88170d0e14f90df180066 (diff)
downloadmpc-git-82df0cc40e47317217878f57acad014ea544f974.tar.gz
added example which triggers a bug in mpc_div
-rw-r--r--src/div.c7
-rw-r--r--tests/div.dat5
2 files changed, 12 insertions, 0 deletions
diff --git a/src/div.c b/src/div.c
index 17f8876..a5395ab 100644
--- a/src/div.c
+++ b/src/div.c
@@ -312,7 +312,13 @@ 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) {
+ /* FIXME: in case overflow_norm is also true, the code below is wrong,
+ since the after division by the norm, we might end up with finite
+ real and/or imaginary parts. A workaround would be to scale the
+ inputs (in case the exponents are within the same range). */
int isinf = 0;
+ /* determine if the real part of res is the maximum or the minimum
+ representable number */
tmpsgn = mpfr_sgn (mpc_realref(res));
if (tmpsgn > 0)
{
@@ -331,6 +337,7 @@ mpc_div (mpc_ptr a, mpc_srcptr b, mpc_srcptr c, mpc_rnd_t rnd)
mpfr_set_inf (mpc_realref(res), tmpsgn);
overflow_re = 1;
}
+ /* same for the imaginary part */
tmpsgn = mpfr_sgn (mpc_imagref(res));
isinf = 0;
if (tmpsgn > 0)
diff --git a/tests/div.dat b/tests/div.dat
index b030382..b3d7fee 100644
--- a/tests/div.dat
+++ b/tests/div.dat
@@ -2484,3 +2484,8 @@
- - 2 0 2 0x1p-1073741823 2 0x3p-1073741824 2 0x1p-1073741823 2 1 2 -1 Z Z
# (1.5+i)*2^emin/(1+i) gives (1.25 - 0.25*i)*2^emin
- + 2 0x1p-1073741823 2 -0 2 0x3p-1073741824 2 0x1p-1073741823 2 1 2 1 Z Z
+
+# example with exact division (0 -1) which works:
+0 0 2 0 2 -1 2 -0x1p50450368 2 0x1p50450368 2 -0x1p50450368 2 -0x1p50450368 N N
+# same with larger exponents, which gives (0 -Inf) in revision 389c43d:
+0 0 2 0 2 -1 2 -0x1p550450368 2 0x1p550450368 2 -0x1p550450368 2 -0x1p550450368 N N