/* DEC *NetFutureValue(net, flows, nflow, intr) * * ARGUMENT * DEC *net, **flows, *intr; * int nflow; * * DESCRIPTION * Calculates the net future value of a series of cash flows. * The nflow cash flows in the array flows are processed at interest * rate intr. The net future value, rounded to two decimal places, * is stored in net. * * SIDE EFFECTS * None. * * RETURNS * net if successful, otherwise GM_NULL. * * POSSIBLE ERRORS * GM_NULLPOINTER * GM_ARGVAL * * AUTHOR * Jared Levy * Copyright (C) 1988-1990 Greenleaf Software Inc. All rights reserved. * * MODIFICATIONS * * */ #include #include "gm.h" #include "gmsystem.h" DEC *NetFutureValue(net, flows, nflow, intr) DEC *net, **flows, *intr; int nflow; { int i; DEC dtemp, *temp=&dtemp, dopi, *opi=&dopi; DEC dtnet, *tnet=&dtnet, dpow, *pow=&dpow; _MacStart(GM_NFV); if (nflow<0) { _MacErr(GM_ARGVAL); _MacRet(GM_NULL); } _MacInVarD(intr); if (!flows||!net) { _MacErr(GM_NULLPOINTER); _MacRet(GM_NULL); } for (i=0;idc.id+=2; (void) _AddDec80Bit(opi, temp, &decOne); _MacDCopy(pow, (&decOne)); for (i=nflow-1;i>=0;i--) { (void) _MulDec80Bit(temp, flows[i], pow); (void) _AddDec80Bit(tnet, tnet, temp); (void) _MulDec80Bit(pow, pow, opi); } _ScaleDec80Bit(net, tnet, 2); _MacRet(net); }