[gnumeric] NT_PI: Extend range.



commit 2fa13cbb87191d02ad499225e0888c710daacd8b
Author: Morten Welinder <terra gnome org>
Date:   Thu Nov 23 18:37:48 2017 -0500

    NT_PI: Extend range.
    
    Don't accidentally go beyond ithprime's limit.

 NEWS                             |    1 +
 plugins/fn-numtheory/ChangeLog   |    6 ++++++
 plugins/fn-numtheory/numtheory.c |    2 +-
 3 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/NEWS b/NEWS
index e850edf..068c971 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@ Morten:
        * Test suite improvements.
        * Improve format guessing for newly entered formulas.
        * Improve PERMUTATIONA for unusual arguments.  [#790742]
+       * Extend range of NT_PI.
 
 --------------------------------------------------------------------------
 Gnumeric 1.12.36
diff --git a/plugins/fn-numtheory/ChangeLog b/plugins/fn-numtheory/ChangeLog
index 7ee0983..771a88d 100644
--- a/plugins/fn-numtheory/ChangeLog
+++ b/plugins/fn-numtheory/ChangeLog
@@ -1,3 +1,9 @@
+2017-11-23  Morten Welinder  <terra gnome org>
+
+       * numtheory.c (compute_nt_pi): When searching for an upper bound,
+       stay below ithprime's limit when possible.  This extends the range
+       for which nt_pi actually works.
+
 2017-11-18  Morten Welinder <terra gnome org>
 
        * Release 1.12.36
diff --git a/plugins/fn-numtheory/numtheory.c b/plugins/fn-numtheory/numtheory.c
index ebd1f5d..76dd445 100644
--- a/plugins/fn-numtheory/numtheory.c
+++ b/plugins/fn-numtheory/numtheory.c
@@ -169,7 +169,7 @@ compute_nt_pi (guint64 n)
 
        while (p < n) {
                lower = upper;
-               upper *= 2;
+               upper = MAX (upper + 1, (MIN (upper * 2, ITHPRIME_LIMIT)));
                if (ithprime (upper, &p))
                        return -1;
        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]