campo-sirio/gfm/ddixt.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

68 lines
1.3 KiB
C
Executable File

/* int _DivTrnDec80Bit(pDst,pSrc1,pSrc2,wID);
*
* ARGUMENT
* DEC *pDst;
* DEC *pSrc1,pSrc2;
* int wID;
*
* DESCRIPTION
* Divides pDst = pSrc1 / pSrc2, truncating result to wId decimal places.
*
* SIDE EFFECTS
* None.
*
* RETURNS
* Returns GM_SUCCESS if successful, otherwise the error code.
* wGMError is not changed.
*
* AUTHOR
* Jared Levy 05-JAN-1987 17:30
* Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved.
*
* MODIFICATIONS
*
*/
#include <stdio.h>
#include "gm.h"
#include "gmsystem.h"
int _DivTrnDec80Bit(pDst,pSrc1,pSrc2,wID)
DEC *pDst;
DEC *pSrc1,*pSrc2;
int wID;
{
int i;
unsigned SHORT s1[14], s2[12]; /* need extra memory */
/* check that pSrc2 is nonzero */
if (_MacIsDecZ(pSrc2))
return(GM_DIV0);
/* check whether scr1 is zero */
if (_MacIsDecZ(pSrc1)) {
_MacDZero(pDst);
pDst->dc.id = wID;
return(GM_SUCCESS);
}
for(i=0;i<5;i++) {
s1[i]=pSrc1->dc.sl[i];
s2[i]=pSrc2->dc.sl[i];
}
s2[5]=0;
if(_DivProcTrn(pDst,s1,s2,pSrc1->dc.id,pSrc2->dc.id,
wID) != GM_SUCCESS)
return(GM_OVERFLOW);
/* if quotient is zero, an underflow has occured */
if (_MacIsDecZ(pDst))
return(GM_UNDERFLOW);
/* if the signs of the sources are different, pDst=-pDst */
pDst->dc.attr = (pSrc1->dc.attr^pSrc2->dc.attr);
return(GM_SUCCESS);
}