From c481bdd7b842503bf646dfb547779871363f20d1 Mon Sep 17 00:00:00 2001 From: daney Date: Thu, 25 Oct 2001 15:02:45 +0000 Subject: coorection for reuse git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@1368 280ebfd0-de03-0410-8827-d642c229c3f4 --- log_base_2.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) (limited to 'log_base_2.c') diff --git a/log_base_2.c b/log_base_2.c index 06c9fb2c5..f64b597b6 100644 --- a/log_base_2.c +++ b/log_base_2.c @@ -49,36 +49,47 @@ mpfr_log2 (r, a, rnd_mode) MPFR_SET_NAN(r); return 1; } - - if (MPFR_IS_ZERO(a)) - { - MPFR_SET_INF(r); - if (MPFR_SIGN(r) > 0) - MPFR_CHANGE_SIGN(r); - DIVIDE_BY_ZERO; /* Execption GMP*/ - return 0; - } - /* If a is negative, the result is NaN */ if (MPFR_SIGN(a) < 0) { - MPFR_SET_NAN(r); - return 1; + if (MPFR_IS_ZERO(a)) + { + MPFR_SET_INF(r); + if (MPFR_SIGN(r) > 0) + MPFR_CHANGE_SIGN(r); + /* Execption GMP*/ + return 0; + } + else + { + MPFR_SET_NAN(r); + return 1; + } } MPFR_CLEAR_NAN(r); /* check for infinity before zero */ if (MPFR_IS_INF(a)) - { + { MPFR_SET_INF(r); - MPFR_SET_SAME_SIGN(r,a); + if(MPFR_SIGN(r) < 0) + MPFR_CHANGE_SIGN(r); return 0; } /* Now we can clear the flags without damage even if r == a */ + MPFR_CLEAR_INF(r); + if (MPFR_IS_ZERO(a)) + { + MPFR_SET_INF(r); + if (MPFR_SIGN(r) > 0) + MPFR_CHANGE_SIGN(r); + /* Execption GMP*/ + return 0; + } /* If a is 1, the result is 0 */ if (mpfr_cmp_ui(a,1) == 0) -- cgit v1.2.1