[gnumeric] GEOMDIST: fix overflow issues.



commit 8d7a5ee417853bdb4b4b3eb834f34c6af0f060f4
Author: Morten Welinder <terra gnome org>
Date:   Fri Jun 11 21:21:23 2010 -0400

    GEOMDIST: fix overflow issues.

 plugins/fn-stat/ChangeLog   |    1 +
 plugins/fn-stat/functions.c |    4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/plugins/fn-stat/ChangeLog b/plugins/fn-stat/ChangeLog
index dbb0255..4a311d7 100644
--- a/plugins/fn-stat/ChangeLog
+++ b/plugins/fn-stat/ChangeLog
@@ -4,6 +4,7 @@
 	functions.
 	(gnumeric_linest, gnumeric_logreg, gnumeric_logest): Simplify
 	using gnm_reg_data_collect.  Fixes #317426.
+	(gnumeric_geomdist): Avoid using "int" for "k".
 
 2010-06-10 Andreas J. Guelzow <aguelzow pyrshep ca>
 
diff --git a/plugins/fn-stat/functions.c b/plugins/fn-stat/functions.c
index 14b22ca..a3d4655 100644
--- a/plugins/fn-stat/functions.c
+++ b/plugins/fn-stat/functions.c
@@ -4433,11 +4433,11 @@ static GnmFuncHelp const help_geomdist[] = {
 static GnmValue *
 gnumeric_geomdist (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
 {
-	int       k   = value_get_as_int (argv[0]);
+	gnm_float k   = gnm_fake_floor (value_get_as_float (argv[0]));
 	gnm_float p   = value_get_as_float (argv[1]);
 	gboolean  cum = value_get_as_checked_bool (argv[2]);
 
-	if (p < 0 || p > 1 || k < 0 || (cum != TRUE && cum != FALSE))
+	if (p < 0 || p > 1 || k < 0)
 		return value_new_error_NUM (ei->pos);
 
 	if (cum)



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