summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2007-11-21 15:19:23 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2007-11-21 15:19:23 +0000
commit4fbc527c33ecbe31ea1f8edfe2f3ba8ddc60e3a9 (patch)
tree4c505a6dd4b5a18f2788f00bc0259d6b56ced845
parent383f14d3f232e31a002d8dee64fd11dfe2c7ab84 (diff)
downloadmpfr-4fbc527c33ecbe31ea1f8edfe2f3ba8ddc60e3a9.tar.gz
Fixed bug in mpfr_div_ui for x=0 and u<>0 (sign of result was not set).
Added testcase. [merged changeset: 4950] git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/branches/2.3@4972 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r--div_ui.c4
-rw-r--r--tests/tdiv_ui.c6
2 files changed, 8 insertions, 2 deletions
diff --git a/div_ui.c b/div_ui.c
index 6bd632a9a..e17d698fe 100644
--- a/div_ui.c
+++ b/div_ui.c
@@ -1,5 +1,4 @@
-/* mpfr_div_ui -- divide a floating-point number by a machine integer
- mpfr_div_si -- divide a floating-point number by a machine integer
+/* mpfr_div_{ui,si} -- divide a floating-point number by a machine integer
Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
Contributed by the Arenaire and Cacao projects, INRIA.
@@ -60,6 +59,7 @@ mpfr_div_ui (mpfr_ptr y, mpfr_srcptr x, unsigned long int u, mp_rnd_t rnd_mode)
else
{
MPFR_SET_ZERO(y);
+ MPFR_SET_SAME_SIGN (y, x);
MPFR_RET(0);
}
}
diff --git a/tests/tdiv_ui.c b/tests/tdiv_ui.c
index ba00ed276..492edc1b3 100644
--- a/tests/tdiv_ui.c
+++ b/tests/tdiv_ui.c
@@ -130,6 +130,12 @@ special (void)
}
}
+ /* Bug reported by Mark Dickinson, 6 Nov 2007 */
+ mpfr_set_si (x, 0, GMP_RNDN);
+ mpfr_set_si (y, -1, GMP_RNDN);
+ mpfr_div_ui (y, x, 4, GMP_RNDN);
+ MPFR_ASSERTN(MPFR_IS_ZERO(y) && MPFR_IS_POS(y));
+
mpfr_clear (x);
mpfr_clear (y);
}