campo-sirio/gfm/pchange.c
alex ba237a9d91 Patch level : no patch
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
2002-02-26 12:19:02 +00:00

60 lines
1.1 KiB
C
Executable File

/* DEC *PercentChange(pDst,pSrc1,pSrc2)
*
* ARGUMENT
* DEC *pDst, *pSrc1, pSrc2;
*
* DESCRIPTION
* Calculates the percent change between pSrc1 and pSrc2 as a percentage
* of pSrc1, stroring the result in pDst.
* pDst = ((pSrc2 - pSrc1) / pSrc1) * 100
* pDst is calculated to maximum precision.
*
* SIDE EFFECTS
* None.
*
* RETURNS
* Returns a pointer to the dest structure unless overflow,
* when it returns a GM_NULL.
*
* POSSIBLE ERROR CODES
*
* GM_NULLPOINTER
* GM_NOMEMORY
* GM_OVERFLOW
* GM_UNDERFLOW
* GM_DIV0
*
* AUTHOR
* Jared Levy
* Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved.
*
* MODIFICATIONS
*
*/
#include <stdio.h>
#include "gm.h"
#include "gmsystem.h"
DEC *PercentChange(pDst,pSrc1,pSrc2)
DEC *pDst;
DEC *pSrc1,*pSrc2;
{
DEC dtemp, *temp=&dtemp, ddiff, *diff=&ddiff;
_MacStart(GM_PCHANGE);
_MacInVarD(pSrc1);
_MacInVarD(pSrc2);
_SubDec80Bit(diff, pSrc2, pSrc1);
_MacDCopy(temp, pSrc1);
temp->dc.id += 2;
pDst = DivideDecimal(pDst, diff, temp);
_MacRet(pDst);
/* error flag set by DivideDecimal */
}