[Gnucash-changes] r13254 - gnucash/trunk/src/calculation - make it
clearer that the return value of 0.0 is an error by using
g_return_val_if_fail - cannot use assert as return value
needs to be modified.
Neil Williams
codehelp at cvs.gnucash.org
Mon Feb 13 06:22:38 EST 2006
Author: codehelp
Date: 2006-02-13 06:22:36 -0500 (Mon, 13 Feb 2006)
New Revision: 13254
Trac: http://svn.gnucash.org/trac/changeset/13254
Modified:
gnucash/trunk/src/calculation/fin.c
Log:
make it clearer that the return value of 0.0 is an error by using g_return_val_if_fail - cannot use assert as return value needs to be modified.
Modified: gnucash/trunk/src/calculation/fin.c
===================================================================
--- gnucash/trunk/src/calculation/fin.c 2006-02-13 09:02:29 UTC (rev 13253)
+++ gnucash/trunk/src/calculation/fin.c 2006-02-13 11:22:36 UTC (rev 13254)
@@ -1199,6 +1199,7 @@
#include <math.h>
#include <string.h>
#include <stdlib.h>
+#include <glib.h>
#define FIN_STATICS
#include "finvar.h"
@@ -1245,7 +1246,7 @@
{
/* if eint == 0.0, all processing _must_ stop or
a recursive loop will start. */
- if (eint == 0.0) { return 0.0; }
+ g_return_val_if_fail(eint == 0.0, 0.0);
return (1.0 + eint * (double) beg) / eint;
} /* _B */
@@ -1254,10 +1255,8 @@
static double
_C (double eint, double pmt, unsigned beg)
{
- double temp = _B (eint, beg);
- unsigned check = (int)temp;
- if(check) return pmt * temp;
- return 0.0;
+ g_return_val_if_fail(eint == 0.0, 0.0);
+ return pmt * _B (eint, beg);
} /* _C */
/* compute Number of Periods from preset data */
@@ -1427,11 +1426,12 @@
unsigned disc,/* discrete/continuous compounding */
unsigned bep) /* beginning/end of period payment */
{
- double eint = eff_int (nint / 100.0, CF, PF, disc);
- double AA = _A (eint, per);
- double BB = _B (eint, bep);
- if(BB == 0.0) return 0.0;
+ double eint, AA, BB;
+ eint = eff_int (nint / 100.0, CF, PF, disc);
+ g_return_val_if_fail(eint == 0.0, 0.0);
+ AA = _A (eint, per);
+ BB = _B (eint, bep);
return -(fv + pv * (AA + 1.0)) / (AA * BB);
} /* _fi_calc_payment */
More information about the gnucash-changes
mailing list