summaryrefslogtreecommitdiff
path: root/mul_2exp.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2001-11-29 03:15:54 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2001-11-29 03:15:54 +0000
commitfe300a2ce7710555c22cda56bffe6905ec1f2d5d (patch)
tree5b64726e9977a59b7450738256361d443313d9c8 /mul_2exp.c
parent2138f3c63f0ae1e5c5551fc99ab2b85bdc02d928 (diff)
downloadmpfr-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 'mul_2exp.c')
-rw-r--r--mul_2exp.c31
1 files changed, 5 insertions, 26 deletions
diff --git a/mul_2exp.c b/mul_2exp.c
index 90d1e2fed..6f3ef9eb3 100644
--- a/mul_2exp.c
+++ b/mul_2exp.c
@@ -24,33 +24,12 @@ MA 02111-1307, USA. */
#include "mpfr.h"
#include "mpfr-impl.h"
+/* Obsolete function, use mpfr_mul_2ui or mpfr_mul_2si instead. */
+
+#undef mpfr_mul_2exp
+
int
mpfr_mul_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_mul_2exp(y, y, LONG_MAX, rnd_mode);
- if (inex2)
- return inex2; /* overflow */
- }
-
- if (__mpfr_emax < MPFR_EMIN_MIN + (long) n ||
- MPFR_EXP(y) > __mpfr_emax - (long) n)
- return mpfr_set_overflow (y, rnd_mode, MPFR_SIGN(y));
-
- MPFR_EXP(y) += (long) n;
- }
-
- return inexact;
+ return mpfr_mul_2ui (y, x, n, rnd_mode);
}