diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2001-11-29 03:15:54 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2001-11-29 03:15:54 +0000 |
commit | fe300a2ce7710555c22cda56bffe6905ec1f2d5d (patch) | |
tree | 5b64726e9977a59b7450738256361d443313d9c8 /div_2exp.c | |
parent | 2138f3c63f0ae1e5c5551fc99ab2b85bdc02d928 (diff) | |
download | mpfr-fe300a2ce7710555c22cda56bffe6905ec1f2d5d.tar.gz |
Functions mpfr_{mul,div}_2{si,ui} added.
Functions mpfr_{mul,div}_2exp still exist for backward compatibility;
they are obsolete and should not be used any longer.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@1587 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'div_2exp.c')
-rw-r--r-- | div_2exp.c | 31 |
1 files changed, 5 insertions, 26 deletions
diff --git a/div_2exp.c b/div_2exp.c index 691fb1be4..3a9f67e21 100644 --- a/div_2exp.c +++ b/div_2exp.c @@ -24,33 +24,12 @@ MA 02111-1307, USA. */ #include "mpfr.h" #include "mpfr-impl.h" +/* Obsolete function, use mpfr_div_2ui or mpfr_div_2si instead. */ + +#undef mpfr_div_2exp + int mpfr_div_2exp (mpfr_ptr y, mpfr_srcptr x, unsigned long int n, mp_rnd_t rnd_mode) { - int inexact; - - inexact = y != x ? mpfr_set (y, x, rnd_mode) : 0; - - if (MPFR_IS_FP(y) && MPFR_NOTZERO(y)) - { - /* n will have to be casted to long to make sure that the addition - and subtraction below (for overflow detection) are signed */ - while (n > LONG_MAX) - { - int inex2; - - n -= LONG_MAX; - inex2 = mpfr_div_2exp(y, y, LONG_MAX, rnd_mode); - if (inex2) - return inex2; /* underflow */ - } - - if (__mpfr_emin > MPFR_EMAX_MAX - (long) n || - MPFR_EXP(y) < __mpfr_emin + (long) n) - return mpfr_set_underflow (y, rnd_mode, MPFR_SIGN(y)); - - MPFR_EXP(y) -= (long) n; - } - - return inexact; + return mpfr_div_2ui (y, x, n, rnd_mode); } |