summaryrefslogtreecommitdiff
path: root/src/log_ui.c
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2016-01-15 11:30:54 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2016-01-15 11:30:54 +0000
commita66f905942f8725efc5efcd75e12b4e03e3f5a88 (patch)
tree0a287bd9158ae226222be2949d9e8f1e091cd5c7 /src/log_ui.c
parent2f9c580b17c6015fe795f609d2886069299de9b8 (diff)
downloadmpfr-a66f905942f8725efc5efcd75e12b4e03e3f5a88.tar.gz
[src/log_ui.c] Added assertions.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@9814 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'src/log_ui.c')
-rw-r--r--src/log_ui.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/log_ui.c b/src/log_ui.c
index 9c8e09699..69ef6f084 100644
--- a/src/log_ui.c
+++ b/src/log_ui.c
@@ -33,6 +33,7 @@ static void
S (mpz_t *P, mpz_t *Q, unsigned long n1, unsigned long n2,
long p, unsigned long k)
{
+ MPFR_ASSERTD (n1 < n2);
if (n2 == n1 + 1)
{
mpz_set_si (P[0], p);
@@ -44,6 +45,7 @@ S (mpz_t *P, mpz_t *Q, unsigned long n1, unsigned long n2,
unsigned long m = (n1 / 2) + (n2 / 2) + (n1 & 1UL & n2);
/* m = floor((n1+n2)/2) */
+ MPFR_ASSERTD (n1 < m && m < n2);
S (P, Q, n1, m, p, k);
S (P + 1, Q + 1, m, n2, p, k);
/* P1/Q1 + (-p)^(m-n1)/2^(k(m-n1)) P2/Q2 =
@@ -127,6 +129,7 @@ mpfr_log_ui (mpfr_ptr x, unsigned long n, mpfr_rnd_t rnd_mode)
mpfr_init2 (tmp, 32);
/* 1354911329/2^31 is a 32-bit upper bound for log(2)/log(3) */
mpfr_set_ui_2exp (tmp, 1354911329, -31, MPFR_RNDU);
+ MPFR_ASSERTN (w <= ULONG_MAX);
mpfr_mul_ui (tmp, tmp, w, MPFR_RNDU);
N = mpfr_get_ui (tmp, MPFR_RNDU);
lgN = MPFR_INT_CEIL_LOG2 (N) + 1;