[gnumeric] cleanups.



commit e5104b44bf99c240ff4fc7d6141ba6c4fd2e1bae
Author: Morten Welinder <terra gnome org>
Date:   Tue Jun 15 13:08:06 2010 -0400

    cleanups.

 ChangeLog          |    7 +++++++
 src/gnm-datetime.c |    2 +-
 src/mathfunc.c     |    6 ++++--
 3 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 499855e..b02724d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-06-15  Morten Welinder  <terra gnome org>
+
+	* src/gnm-datetime.c (datetime_value_to_seconds): Improve sanity
+	check.
+
+	* src/mathfunc.c (pbeta): Simplify.
+
 2010-06-14 Andreas J. Guelzow <aguelzow pyrshep ca>
 
 	* src/mathfunc.c (pbinom2): pbinom's right tail calculation
diff --git a/src/gnm-datetime.c b/src/gnm-datetime.c
index 5d74467..c517563 100644
--- a/src/gnm-datetime.c
+++ b/src/gnm-datetime.c
@@ -321,7 +321,7 @@ datetime_value_to_seconds (GnmValue const *v, GODateConventions const *conv)
 {
 	int secs;
 	gnm_float d = datetime_value_to_serial_raw (v, conv);
-	if (d == G_MAXINT)
+	if (d >= G_MAXINT || d < G_MININT)
 		return -1;
 
 	/* Add epsilon before we scale and translate because otherwise it
diff --git a/src/mathfunc.c b/src/mathfunc.c
index a6bbc02..730cfb7 100644
--- a/src/mathfunc.c
+++ b/src/mathfunc.c
@@ -5799,10 +5799,11 @@ binomial (gnm_float ii, gnm_float jj, gnm_float pp, gnm_float qq,
 	return binomialcf (ii, jj, pp, qq, diffFromMean, lower_tail, log_p);
 }
 
-
 gnm_float
 pbeta (gnm_float x, gnm_float a, gnm_float b, gboolean lower_tail, gboolean log_p)
 {
+	gnm_float am1;
+
 	if (gnm_isnan (x) || gnm_isnan (a) || gnm_isnan (b))
 		return x + a + b;
 
@@ -5821,7 +5822,8 @@ pbeta (gnm_float x, gnm_float a, gnm_float b, gboolean lower_tail, gboolean log_
 	if (b < 1)
 		return binomial (-b, a, 1 - x, x, 0, lower_tail, log_p);
 
-	return binomial (a - 1, b, x, 1 - x, (a + b - 1) * x - a + 1,
+	am1 = a - 1;
+	return binomial (am1, b, x, 1 - x, (am1 + b) * x - am1,
 			 !lower_tail, log_p);
 }
 



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