diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2003-03-28 12:56:46 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2003-03-28 12:56:46 +0000 |
commit | 663efca2882769e7012af349dbb9d11f758f9a9b (patch) | |
tree | 9225f230e50c4a284ffb035b805de0b1e97163ab /exp3.c | |
parent | e94c80c59c89c185962d674592300d59e723a4e9 (diff) | |
download | mpfr-663efca2882769e7012af349dbb9d11f758f9a9b.tar.gz |
Added some asserts.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2283 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'exp3.c')
-rw-r--r-- | exp3.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -1,6 +1,6 @@ /* mpfr_exp -- exponential of a floating-point number -Copyright 1999, 2001, 2002 Free Software Foundation, Inc. +Copyright 1999, 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the MPFR Library. @@ -19,14 +19,12 @@ 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 <stdio.h> +#include <limits.h> #include "gmp.h" #include "gmp-impl.h" #include "mpfr.h" #include "mpfr-impl.h" -static int mpfr_exp_rational _PROTO ((mpfr_ptr, mpz_srcptr, int, int)); - static int mpfr_exp_rational (mpfr_ptr y, mpz_srcptr p, int r, int m) { @@ -42,6 +40,7 @@ mpfr_exp_rational (mpfr_ptr y, mpz_srcptr p, int r, int m) TMP_DECL (marker); TMP_MARK (marker); + MPFR_ASSERTN(m < sizeof(int) * CHAR_BIT - 1); n = 1 << m; P = (mpz_t*) TMP_ALLOC((m+1) * sizeof(mpz_t)); S = (mpz_t*) TMP_ALLOC((m+1) * sizeof(mpz_t)); @@ -63,6 +62,7 @@ mpfr_exp_rational (mpfr_ptr y, mpz_srcptr p, int r, int m) mpz_set_ui(P[k], i+1); mpz_set(S[k], P[k]);; j=i+1; l=0; while ((j & 1) == 0) { + MPFR_ASSERTN(l < sizeof(int) * CHAR_BIT - 1); mpz_mul(S[k], S[k], ptoj[l]); mpz_mul(S[k-1], S[k-1], P[k]); mpz_mul_2exp(S[k-1], S[k-1], r*(1<<l)); @@ -179,6 +179,7 @@ mpfr_exp3 (mpfr_ptr y, mpfr_srcptr x, mp_rnd_t rnd_mode) } mpfr_mul(tmp,tmp,t,GMP_RNDD); + MPFR_ASSERTN(twopoweri <= INT_MAX/2); twopoweri <<= 1; } mpfr_clear (t); |