ba237a9d91
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
98 lines
1.7 KiB
C
Executable File
98 lines
1.7 KiB
C
Executable File
/* DEC *CotangentDecimal(pDst,pSrc)
|
|
*
|
|
* ARGUMENT
|
|
* DEC *pDst;
|
|
* DEC *pSrc;
|
|
*
|
|
* DESCRIPTION
|
|
* Sets pDst = the cotangent of pSrc radians.
|
|
*
|
|
* RETURNS
|
|
* Returns pointer to pDst if successful, otherwise a GM_NULL.
|
|
*
|
|
* POSSIBLE ERROR CODES
|
|
*
|
|
* GM_NULLPOINTER
|
|
* GM_OVERFLOW
|
|
* GM_IMAG if pSrc = 0
|
|
*
|
|
* AUTHOR
|
|
* Jared Levy Oct 16, 1987
|
|
* Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved.
|
|
*
|
|
* ALGORITHM
|
|
* tan(x) = +/- (1 - cos(x) ^ 2 ) ^ .5 / cos(x)
|
|
*
|
|
* MODIFICATIONS
|
|
*
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include "gm.h"
|
|
#include "gmsystem.h"
|
|
|
|
DEC *CotangentDecimal(pDst,pSrc)
|
|
DEC *pDst;
|
|
DEC *pSrc;
|
|
|
|
{
|
|
int i, isn=0;
|
|
DEC *nsrc, dnsrc, *size, dsize, *temp, dtemp;
|
|
DEC *cosx, dcosx, *sinx, dsinx;
|
|
|
|
_MacStart(GM_DCOT);
|
|
|
|
_MacInVarD(pSrc)
|
|
_MacOutVarD(pDst);
|
|
|
|
if(_MacIsDecZ(pSrc)) {
|
|
_MacErr(GM_IMAG);
|
|
_MacRet(GM_NULL);
|
|
}
|
|
|
|
nsrc = &dnsrc;
|
|
(void) _SubDec80Bit(nsrc, &decPiOver2, pSrc);
|
|
if (_MacIsDecN(nsrc)) {
|
|
isn = 1;
|
|
_MacDChgs(nsrc);
|
|
}
|
|
|
|
temp = &dtemp;
|
|
if (CompareDecimal(nsrc, &decPiOver2) == 1) {
|
|
(void) _DivRndDec80Bit(size = &dsize, nsrc, &decPi, 0);
|
|
(void) _MulDec80Bit(temp, &decPi, size);
|
|
(void) _SubDec80Bit(nsrc, nsrc, temp);
|
|
if (_MacIsDecN(nsrc)) {
|
|
isn = 1 - isn;
|
|
_MacDChgs(nsrc);
|
|
}
|
|
}
|
|
|
|
_CosDec80Bit(cosx = &dcosx, nsrc);
|
|
if (_MacIsDecZ(cosx)) {
|
|
_MacErr(GM_OVERFLOW);
|
|
_MacRet(GM_NULL);
|
|
}
|
|
|
|
(void) _MulDec80Bit(temp, cosx, cosx);
|
|
(void) _SubDec80Bit(temp, &decOne, temp);
|
|
_SqrtDec80Bit(sinx = &dsinx, temp);
|
|
i = _DivDec80Bit(pDst, sinx, cosx);
|
|
|
|
if (i == GM_OVERFLOW) {
|
|
_MacErr(GM_OVERFLOW);
|
|
_MacRet(GM_NULL);
|
|
}
|
|
|
|
i = _Sq5UnsTo4Uns(pDst);
|
|
if (i != GM_SUCCESS) {
|
|
_MacErr(GM_OVERFLOW);
|
|
_MacRet(GM_NULL);
|
|
}
|
|
|
|
if (isn)
|
|
_MacDChgs(pDst);
|
|
|
|
_MacRet(pDst);
|
|
}
|