[gnumeric] NPER: handler rates (-100%; 0%) too.
- From: Morten Welinder <mortenw src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnumeric] NPER: handler rates (-100%; 0%) too.
- Date: Tue, 9 Jun 2009 11:32:33 -0400 (EDT)
commit bfeeface878baf99bd6c210aa19fc0adb557cf9f
Author: Morten Welinder <terra gnome org>
Date: Tue Jun 9 11:32:00 2009 -0400
NPER: handler rates (-100%; 0%) too.
---
NEWS | 2 ++
plugins/fn-financial/ChangeLog | 7 +++++++
plugins/fn-financial/functions.c | 12 ++++++++----
3 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/NEWS b/NEWS
index a7292cd..de09941 100644
--- a/NEWS
+++ b/NEWS
@@ -19,6 +19,8 @@ Morten:
* Honour --geometry even when not loading a file.
* Fix increase/decrease precision for accounting formats.
* Fix array editing criticals. [#584746]
+ * Fix style problems with operator.xls. [#585178]
+ * Fix NPER problems.
--------------------------------------------------------------------------
Gnumeric 1.9.8
diff --git a/plugins/fn-financial/ChangeLog b/plugins/fn-financial/ChangeLog
index cf33a93..57f4c1e 100644
--- a/plugins/fn-financial/ChangeLog
+++ b/plugins/fn-financial/ChangeLog
@@ -1,3 +1,10 @@
+2009-06-09 Morten Welinder <terra gnome org>
+
+ * functions.c (gnumeric_nper): Negative rates make sense down to,
+ but not including -100%. Fixes bug reported at
+ http://www.oasis-open.org/committees/download.php/32469/OpenDocument-formula-20090508.odt
+ on page 184. Hint: there are better places to report problems.
+
2009-05-23 Morten Welinder <terra gnome org>
* Release 1.9.8
diff --git a/plugins/fn-financial/functions.c b/plugins/fn-financial/functions.c
index 4565576..dab2934 100644
--- a/plugins/fn-financial/functions.c
+++ b/plugins/fn-financial/functions.c
@@ -2252,11 +2252,15 @@ gnumeric_nper (GnmFuncEvalInfo *ei, GnmValue const * const *argv)
gnm_float fv = argv[3] ? value_get_as_float (argv[3]) : 0;
int type = value_get_paytype (argv[4]);
- if (rate == 0 && pmt != 0)
- return value_new_float (-(fv + pv) / pmt);
+ if (rate == 0) {
+ if (pmt == 0)
+ return value_new_error_DIV0 (ei->pos);
+ else
+ return value_new_float (-(fv + pv) / pmt);
+ }
- if (rate <= 0.0)
- return value_new_error_DIV0 (ei->pos);
+ if (rate <= -1)
+ return value_new_error_NUM (ei->pos);
if (!is_valid_paytype (type))
return value_new_error_VALUE (ei->pos);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]