Files correlati : Ricompilazione Demo : [ ] Commento : Aggiunti i sorgenti per Greenleaf Math Library (gfm.dll) git-svn-id: svn://10.65.10.50/trunk@10079 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			74 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			74 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
| /* DEC	*SinglePaymentFutureValue(dst, intr, nper);
 | |
|  *
 | |
|  * ARGUMENT
 | |
|  *	DEC	*dst,*intr;
 | |
|  *	int	nper;
 | |
|  *
 | |
|  * DESCRIPTION
 | |
|  *	Calculates the future value in nper periods of 1 dollar	at the
 | |
|  *   present time at an	interest rate of intr percent per period.
 | |
|  *   dst = (1 +	intr / 100) ^ nper
 | |
|  *
 | |
|  * SIDE	EFFECTS
 | |
|  *	The result is stored in	dst.
 | |
|  *
 | |
|  * RETURNS
 | |
|  *	dst 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 <stdio.h>
 | |
| #include "gmsystem.h"
 | |
| DEC	*SinglePaymentFutureValue(dst, intr, nper)
 | |
| DEC	*dst,*intr;
 | |
| int	nper;
 | |
| {
 | |
| 	DEC	dtemp, *temp=&dtemp;
 | |
| 	int	i;
 | |
| 
 | |
| 	_MacStart(GM_SPFV);
 | |
| 
 | |
| 	_MacInVarD(intr);
 | |
| 	_MacOutVarD(dst);
 | |
| 
 | |
| /* interest rate must be greater than -100% */
 | |
| 	if (CompareDecimal(intr,&decMinusHundred)<=0)  {
 | |
| 		_MacErr(GM_ARGVAL);
 | |
| 		_MacRet(GM_NULL);
 | |
| 	}
 | |
| 
 | |
| 	_MacDCopy(temp,	intr);
 | |
| 	temp->dc.id +=2;
 | |
| 	(void) _AddDec80Bit(temp, temp,	&decOne);
 | |
| 	i =  _IntPwrDec80Bit(temp, temp, nper);
 | |
| 
 | |
| 	if (i==GM_OVERFLOW)  {
 | |
| 		_MacErr(GM_ARGVAL);
 | |
| 		_MacRet(GM_NULL);
 | |
| 	}
 | |
| 
 | |
| 	if (_Sq5UnsTo4Uns(temp)!=GM_SUCCESS)  {
 | |
| 		_MacErr(GM_ARGVAL);
 | |
| 		_MacRet(GM_NULL);
 | |
| 	}
 | |
| 
 | |
| 	_MacDCopy(dst, temp);
 | |
| 
 | |
| /* can't have zero value */
 | |
| 	if (_MacIsDecZ(temp))
 | |
| 		_MacErr(GM_ARGVAL);
 | |
| 
 | |
| 	_MacRet(temp);
 | |
| }
 |