campo-sirio/gfm/ddixf.c

58 lines
1.1 KiB
C
Raw Normal View History

/* int _DivDecFast(pDst,pSrc1,pSrc2);
*
* ARGUMENT
* DEC *pDst;
* DEC *pSrc1,pSrc2;
*
* DESCRIPTION
* Divides pDst = pSrc1 / pSrc2, to 64 bits of accuracy.
* This code is about 1/3 faster than ddix.
*
* 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 _DivProcFast();
int _DivDecFast(pDst,pSrc1,pSrc2)
DEC *pDst;
DEC *pSrc1,*pSrc2;
{
/* check that pSrc2 is nonzero */
if (_MacIsDecZ(pSrc2))
return(GM_DIV0);
/* check whether scr1 is zero */
if (_MacIsDecZ(pSrc1)) {
_MacDCopy(pDst, pSrc1);
return(GM_SUCCESS);
}
if (_DivProcFast(pDst,pSrc1,pSrc2) != 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);
}