From 3035f62d87667e08ac5370bca1e47fe8f683c2e8 Mon Sep 17 00:00:00 2001 From: hanrot Date: Wed, 13 Dec 2000 14:50:13 +0000 Subject: Take into account Inf, Nans ; clear the flags of the return variable in most function calls. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@851 280ebfd0-de03-0410-8827-d642c229c3f4 --- ui_div.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'ui_div.c') diff --git a/ui_div.c b/ui_div.c index 8ee60aaf7..3cdb29acf 100644 --- a/ui_div.c +++ b/ui_div.c @@ -43,6 +43,14 @@ mpfr_ui_div(y, u, x, rnd_mode) unsigned long cnt; TMP_DECL(marker); + if (MPFR_IS_NAN(x)) { MPFR_SET_NAN(y); return; } + if (MPFR_IS_INF(y)) + { + MPFR_SET_ZERO(x); + if (MPFR_SIGN(x) != MPFR_SIGN(y)) { MPFR_CHANGE_SIGN(y); } + return; + } + if (u) { TMP_MARK(marker); MON_INIT(up, uu, BITS_PER_MP_LIMB, 1); @@ -54,5 +62,8 @@ mpfr_ui_div(y, u, x, rnd_mode) TMP_FREE(marker); } - else MPFR_SET_ZERO(y); /* if u=0, then set y to 0 */ + else { + if (MPFR_IS_ZERO(x)) { MPFR_SET_NAN(y); } + else MPFR_SET_ZERO(y); /* if u=0, then set y to 0 */ + } } -- cgit v1.2.1