68 lines
1.3 KiB
C
68 lines
1.3 KiB
C
|
/* void _CosDec80Bit(pDst,pSrc)
|
||
|
*
|
||
|
* ARGUMENT
|
||
|
* DEC *pDst, *pSrc;
|
||
|
*
|
||
|
* DESCRIPTION
|
||
|
* Sets pDst = the cosine of pSrc radians.
|
||
|
*
|
||
|
* SIDE EFFECTS
|
||
|
* None.
|
||
|
*
|
||
|
* RETURNS
|
||
|
* None. No errors are possible.
|
||
|
*
|
||
|
* AUTHOR
|
||
|
* Jared Levy October 16, 1987
|
||
|
* Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved.
|
||
|
*
|
||
|
* MODIFICATIONS
|
||
|
*
|
||
|
*/
|
||
|
|
||
|
#include <stdio.h>
|
||
|
#include "gm.h"
|
||
|
#include "gmsystem.h"
|
||
|
|
||
|
void _CosDec80Bit(pDst,pSrc)
|
||
|
DEC *pDst, *pSrc;
|
||
|
{
|
||
|
DEC dnsrc, *nsrc, dtemp, *temp;
|
||
|
int isn=0;
|
||
|
|
||
|
nsrc = &dnsrc;
|
||
|
_MacDCopy(nsrc, pSrc);
|
||
|
|
||
|
/* scale nsrc to range 0 to pi */
|
||
|
if (_MacIsDecN(nsrc))
|
||
|
_MacDChgs(nsrc);
|
||
|
|
||
|
if (CompareDecimal(nsrc, &decPi) == 1) {
|
||
|
temp = &dtemp;
|
||
|
(void) _DivRndDec80Bit(temp, nsrc, &dec2Pi, 0);
|
||
|
(void) _MulDec80Bit(temp, temp, &dec2Pi);
|
||
|
(void) _SubDec80Bit(nsrc, nsrc, temp);
|
||
|
if (_MacIsDecN(nsrc))
|
||
|
_MacDChgs(nsrc);
|
||
|
}
|
||
|
|
||
|
/* scale nsrc to range 0 to pi / 2 */
|
||
|
if (CompareDecimal(nsrc, &decPiOver2) == 1) {
|
||
|
isn = 1;
|
||
|
(void) _SubDec80Bit(nsrc, &decPi, nsrc);
|
||
|
}
|
||
|
|
||
|
/* calculate appropriate Taylor series */
|
||
|
if (CompareDecimal(nsrc, &decPiOver4) == 1) {
|
||
|
(void) _SubDec80Bit(nsrc, &decPiOver2, nsrc);
|
||
|
_SinDecSmall(pDst, nsrc); /* sine series */
|
||
|
}
|
||
|
else
|
||
|
_CosDecSmall(pDst, nsrc); /* cosine series */
|
||
|
|
||
|
/* adjust for negative values */
|
||
|
if (isn)
|
||
|
_MacDChgs(pDst);
|
||
|
|
||
|
}
|