[Gnucash-changes] r13253 - gnucash/trunk/src/calculation -
preventing data loss in normal use - retain unsigned int
check for zero as a special case error state indicating
immediate abort.
Neil Williams
codehelp at cvs.gnucash.org
Mon Feb 13 04:02:30 EST 2006
Author: codehelp
Date: 2006-02-13 04:02:29 -0500 (Mon, 13 Feb 2006)
New Revision: 13253
Trac: http://svn.gnucash.org/trac/changeset/13253
Modified:
gnucash/trunk/src/calculation/fin.c
Log:
preventing data loss in normal use - retain unsigned int check for zero as a special case error state indicating immediate abort.
Modified: gnucash/trunk/src/calculation/fin.c
===================================================================
--- gnucash/trunk/src/calculation/fin.c 2006-02-13 05:05:55 UTC (rev 13252)
+++ gnucash/trunk/src/calculation/fin.c 2006-02-13 09:02:29 UTC (rev 13253)
@@ -1243,15 +1243,10 @@
static double
_B (double eint, unsigned beg)
{
- /* the following should call an error routine to report the error */
- if (eint == 0.0)
- {
- fprintf (stderr, "Zero Interest.\n");
- fflush(stderr);
- return 0.0;
-/* exit (1);*/
- } /* endif */
-
+ /* if eint == 0.0, all processing _must_ stop or
+ a recursive loop will start. */
+ if (eint == 0.0) { return 0.0; }
+
return (1.0 + eint * (double) beg) / eint;
} /* _B */
@@ -1259,8 +1254,9 @@
static double
_C (double eint, double pmt, unsigned beg)
{
- unsigned check = _B (eint, beg);
- if(check) return pmt * check;
+ double temp = _B (eint, beg);
+ unsigned check = (int)temp;
+ if(check) return pmt * temp;
return 0.0;
} /* _C */
@@ -1534,7 +1530,7 @@
double AA = _A (eint, per);
double CC = _C (eint, pmt, bep);
double D = (AA + 1.0) / (1.0 + eint);
- if(CC == 0) return 0.0;
+ if(CC == 0.0) return 0.0;
return (double) per *(pv + CC) * D - (AA * CC) / eint;
} /* fip */
More information about the gnucash-changes
mailing list