/* 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 #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); }