From 6e879c6f3361346ede165d0733a26e9145cccf69 Mon Sep 17 00:00:00 2001 From: vlefevre Date: Fri, 1 Feb 2002 21:35:34 +0000 Subject: Misc bug fixes and code clean-up. git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@1678 280ebfd0-de03-0410-8827-d642c229c3f4 --- asinh.c | 54 ++++++++++++++++++++++++------------------------------ 1 file changed, 24 insertions(+), 30 deletions(-) (limited to 'asinh.c') diff --git a/asinh.c b/asinh.c index a4ab317af..ac6de2595 100644 --- a/asinh.c +++ b/asinh.c @@ -1,6 +1,6 @@ /* mpfr_asinh -- Inverse Hyperbolic Sinus of Unsigned Integer Number -Copyright (C) 2001 Free Software Foundation. +Copyright (C) 2001-2002 Free Software Foundation. This file is part of the MPFR Library. @@ -29,51 +29,45 @@ MA 02111-1307, USA. */ asinh= ln(x+sqrt(x^2+1)) */ int -mpfr_asinh (mpfr_ptr y, mpfr_srcptr xt , mp_rnd_t rnd_mode) +mpfr_asinh (mpfr_ptr y, mpfr_srcptr xt, mp_rnd_t rnd_mode) { - int inexact =0; + int inexact; mpfr_t x; int flag_neg=0; + mp_prec_t Nx; - mp_prec_t Nx=MPFR_PREC(xt); /* Precision of input variable */ - mpfr_init2(x,Nx); - mpfr_set(x,xt,GMP_RNDN); - - if (MPFR_SIGN(x) < 0) - { - MPFR_CHANGE_SIGN(x); - flag_neg=1; - } - - if (MPFR_IS_NAN(x)) + if (MPFR_IS_NAN(xt)) { MPFR_SET_NAN(y); - mpfr_clear(x); - return 1; + MPFR_RET_NAN; } + MPFR_CLEAR_NAN(y); - - if (MPFR_IS_INF(x)) + if (MPFR_IS_INF(xt)) { MPFR_SET_INF(y); - MPFR_SET_SAME_SIGN(y,x); - if(flag_neg) - MPFR_CHANGE_SIGN(y); - mpfr_clear(x); - return 1; + MPFR_SET_SAME_SIGN(y, xt); + MPFR_RET(0); } MPFR_CLEAR_INF(y); - if(!MPFR_NOTZERO(x)) + if (MPFR_IS_ZERO(xt)) { MPFR_SET_ZERO(y); /* asinh(0) = 0 */ - MPFR_SET_SAME_SIGN(y,x); - if(flag_neg) - MPFR_CHANGE_SIGN(y); - mpfr_clear(x); - return 0; + MPFR_SET_SAME_SIGN(y, xt); + MPFR_RET(0); + } + + Nx = MPFR_PREC(xt); /* Precision of input variable */ + mpfr_init2(x, Nx); + mpfr_set(x, xt, GMP_RNDN); + + if (MPFR_SIGN(x) < 0) + { + MPFR_CHANGE_SIGN(x); + flag_neg=1; } /* General case */ @@ -132,5 +126,5 @@ mpfr_asinh (mpfr_ptr y, mpfr_srcptr xt , mp_rnd_t rnd_mode) mpfr_clear(te); } mpfr_clear(x); - return inexact; + MPFR_RET(inexact); } -- cgit v1.2.1