campo-sirio/gfm/advpmt.c

56 lines
1.2 KiB
C
Raw Normal View History

/* DEC *AdvancePayment(nper, intr, pv, pmt, fv, ad, opt)
*
* ARGUMENT
* int nper, ad, opt;
* DEC *intr, *pv, *pmt, *fv;
*
* DESCRIPTION
* Given five variables involved in compound interest, solves for the
* sixth one. The variables are the number of periods nper, the percentage
* interest rate per period intr, the present value pv, the periodic payment
* pmt, the future value fv, and the number of advanced payments ad,
* while opt tells which variable to solve for.
*
* SIDE EFFECTS
* Changes value of unknown variable.
*
* RETURNS
* In case of success when not solving for nper, the result is returned.
* If solving for nper or if an error occurs, GM_NULL is returned.
*
* POSSIBLE ERRORS
* GM_NULLPOINTER
* GM_ARGVAL
*
*
* AUTHOR
* Jared Levy
* Copyright (C) 1988-1990 Greenleaf Software Inc. All rights reserved.
*
* MODIFICATIONS
*
*
*/
#include <stdio.h>
#include "gm.h"
#include "gmsystem.h"
DEC *AdvancePayment(nper, intr, pv, pmt, fv, ad, opt)
int nper, ad, opt;
DEC *intr, *pv, *pmt, *fv;
{
DEC *p;
_MacStart(GM_ADVPMT);
if (opt==GM_N || ad>=nper || ad<0) {
_MacErr(GM_ARGVAL);
_MacRet(GM_NULL);
}
p=_CompoundAux(0, &nper, intr, intr, pv, pmt, fv, ad, opt);
_MacRet(p);
}