summaryrefslogtreecommitdiff
path: root/exp2.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2003-01-07 01:46:51 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2003-01-07 01:46:51 +0000
commit247a7c9418dbdcc0161d8afadc3776bd2550bf64 (patch)
tree4803a0a8fe71b7d4cf1a48b77e84a32fd9d2d193 /exp2.c
parent6883e76f9871a58dd70e8cdd560060397c47fe51 (diff)
downloadmpfr-247a7c9418dbdcc0161d8afadc3776bd2550bf64.tar.gz
Added assertions that can be resolved at compile time: the exponents
must be representable in a long int (IMHO, this limitation should be avoided in a clean way). git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2139 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'exp2.c')
-rw-r--r--exp2.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/exp2.c b/exp2.c
index 21ec72f45..d9483de12 100644
--- a/exp2.c
+++ b/exp2.c
@@ -1,6 +1,6 @@
/* mpfr_exp2 -- power of 2 function 2^y
-Copyright 2001, 2002 Free Software Foundation.
+Copyright 2001, 2002, 2003 Free Software Foundation.
This file is part of the MPFR Library.
@@ -19,6 +19,7 @@ along with the MPFR Library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
MA 02111-1307, USA. */
+#include <limits.h>
#include "gmp.h"
#include "gmp-impl.h"
#include "mpfr.h"
@@ -64,6 +65,7 @@ mpfr_exp2 (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode)
/* since the smallest representable non-zero float is 1/2*2^__gmpfr_emin,
if x < __gmpfr_emin - 1, the result is either 1/2*2^__gmpfr_emin or 0 */
+ MPFR_ASSERTN(MPFR_EMIN_MIN - 1 >= LONG_MIN);
if (mpfr_cmp_si_2exp (x, __gmpfr_emin - 1, 0) < 0)
return mpfr_set_underflow (y, rnd_mode, 1);
@@ -71,6 +73,7 @@ mpfr_exp2 (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode)
{
double xd;
+ MPFR_ASSERTN(MPFR_EMAX_MAX <= LONG_MAX);
if (mpfr_cmp_si_2exp (x, __gmpfr_emax, 0) > 0)
return mpfr_set_overflow (y, rnd_mode, 1);