Neil,

Quoting Neil Williams <[EMAIL PROTECTED]>:

@@ -1257,7 +1259,9 @@
static double
_C (double eint, double pmt, unsigned beg)
{
-  return pmt * _B (eint, beg);
+  unsigned check = _B (eint, beg);
+  if(check) return pmt * check;
+  return 0.0;
}                               /* _C */

I'm not convinced this patch is correct.  _B() returns a double, but
you're assigning it to an unsigned -- so you're going to lose data
in the case.   I also don't see why it matters here; there's nothing
illegal about multiplying by zero.

@@ -1431,6 +1434,7 @@
  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;

You're also inconsistent with your checks.  Sometimes you say:
 if (foo)
and others (like here) you say:
 if (foo == 0.0)

Any particular reason for the inconsistency?  Could we choose one
for a particular patchset?

  return -(fv + pv * (AA + 1.0)) / (AA * BB);
}                               /* _fi_calc_payment */
@@ -1530,7 +1534,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;

And yet another inconsistency --  == 0 instead of == 0.0.

Are you sure this code even still works?  Is there a test case that shows
the actual bug(s)?

-derek

--
      Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
      Member, MIT Student Information Processing Board  (SIPB)
      URL: http://web.mit.edu/warlord/    PP-ASEL-IA     N1NWH
      [EMAIL PROTECTED]                        PGP key available

_______________________________________________
gnucash-devel mailing list
[email protected]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel

Reply via email to