/* DEC *NetPresentValue(net, flows, nflow, intr) * * ARGUMENT * DEC *net, **flows, *intr; * int nflow; * * DESCRIPTION * Calculates the net present value of a series of cash flows. * The nflow cash flows in the array flows are processed at interest * rate intr. The net present 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 *NetPresentValue(net, flows, nflow, intr) DEC *net, **flows, *intr; int nflow; { int i; DEC dtemp, *temp=&dtemp, dooopi, *ooopi=&dooopi; DEC dtnet, *tnet=&dtnet, dpow, *pow=&dpow; _MacStart(GM_NPV); 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(temp, temp, &decOne); (void) _DivDec80Bit(ooopi, &decOne, temp); _MacDCopy(pow, (&decOne)); for (i=0;i