gnumeric r17169 - in trunk: . plugins/numtheory



Author: mortenw
Date: Sun Mar  1 21:18:24 2009
New Revision: 17169
URL: http://svn.gnome.org/viewvc/gnumeric?rev=17169&view=rev

Log:
2009-03-01  Morten Welinder  <terra gnome org>

	* numtheory.c (prime_factor): Change result type to guint64.
	(gnumeric_pfactor): Keep factor in guint64, not int.



Modified:
   trunk/NEWS
   trunk/plugins/numtheory/ChangeLog
   trunk/plugins/numtheory/numtheory.c

Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS	(original)
+++ trunk/NEWS	Sun Mar  1 21:18:24 2009
@@ -4,6 +4,7 @@
 	* Fix multihead issues with cell comments.
 	* Fix multihead issue with sheet reordering.
 	* Fix multihead issues with tooltips.
+	* Fix PFACTOR to handle huge factors.
 
 --------------------------------------------------------------------------
 Gnumeric 1.9.4

Modified: trunk/plugins/numtheory/numtheory.c
==============================================================================
--- trunk/plugins/numtheory/numtheory.c	(original)
+++ trunk/plugins/numtheory/numtheory.c	Sun Mar  1 21:18:24 2009
@@ -51,7 +51,7 @@
 }
 
 #define PTABLE_CHUNK 64
-#define ITHPRIME_LIMIT (1 << 20)
+#define ITHPRIME_LIMIT (1 << 30)
 static gint *prime_table = NULL;
 
 /* Calculate the i-th prime.  Returns TRUE on error.  */
@@ -424,7 +424,7 @@
  *    0 (n <= 1)
  *    smallest prime facter
  */
-static int
+static guint64
 prime_factor (guint64 n)
 {
 	int i = 1, p = 2;
@@ -437,6 +437,7 @@
 			return -1;
 		if (n % p == 0)
 			return p;
+
 	}
 
 	return n;
@@ -461,7 +462,7 @@
 gnumeric_pfactor (GnmFuncEvalInfo *ei, GnmValue const * const *args)
 {
 	gnm_float n = gnm_floor (value_get_as_float (args[0]));
-	int p;
+	guint64 p;
 
 	if (n < 2)
 		return value_new_error_VALUE (ei->pos);
@@ -473,7 +474,7 @@
 	if (p < 0)
 		return value_new_error (ei->pos, OUT_OF_BOUNDS);
 
-	return value_new_int (p);
+	return value_new_float (p);
 }
 
 /* ------------------------------------------------------------------------- */



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