home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
xbase
/
library
/
clipper
/
rettig
/
source
/
depvaldb.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-10-21
|
1KB
|
44 lines
/*********
*
* DEPVALDB.C
*
* by Ralph Davis
* modified by Tom Rettig
*
* Placed in the public domain by Tom Rettig Associates, 10/22/1990.
*
*********/
/* DEPVALDB: Depreciated value by declining-balance method
Computes current value of an asset
by declining balance method.
Assumes fixed rate of depreciation per period.
SYNTAX: DEPVALDB(value, rate, periods)
where value = current value
rate = rate of depreciation per period
periods = number of periods elapsed
RETURNS: depreciated value at end of period.
Equation = value * (( 1 - rate)^periods)
*/
#include "trlib.h"
TRTYPE depvaldb()
{
if ( PCOUNT==3 && ISNUM(1) && ISNUM(2) && ISNUM(3) )
{
double value = _parnd(1);
double rate = _parnd(2);
double periods = _parnd(3);
_retnd(value * pow(1.0 - rate, periods));
}
else
_retnd( (double)ERROR );
}