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

81 lines
1.5 KiB
C
Executable File

/* DEC *ArcCosineDecimal(pDst,pSrc)
*
* ARGUMENT
* DEC *pDst;
* DEC *pSrc;
*
* DESCRIPTION
* Sets pDst = the arccosine (in radians) of pSrc,
* which always lies between 0 and pi
*
* RETURNS
* Returns pointer to pDst if successful, otherwise a GM_NULL.
*
* POSSIBLE ERROR CODES
*
* GM_NULLPOINTER
* GM_IMAG if | pSrc | > 1
*
* AUTHOR
* Jared Levy Aug 7, 1987
* Copyright (C) 1987-1990 Greenleaf Software Inc. All rights reserved.
*
* MODIFICATIONS
*
*/
#include <stdio.h>
#include "gm.h"
#include "gmsystem.h"
DEC *ArcCosineDecimal(pDst,pSrc)
DEC *pDst;
DEC *pSrc;
{
int isn = 0;
DEC *nsrc, dnsrc, *temp1, dtemp1, *temp2, dtemp2;
DEC *temp3, dtemp3, *temp4, dtemp4;
_MacStart(GM_DACOS);
_MacInVar(pSrc,GM_NULL);
_MacOutVar(pDst,GM_NULL);
nsrc = &dnsrc;
_MacDCopy(nsrc, pSrc);
if (_MacIsDecN(nsrc)) {
isn = 1;
_MacDChgs(nsrc);
}
if ((CompareDecimal(nsrc,&decOne)) == 1) {
_MacErr(GM_IMAG);
_MacRet(GM_NULL);
}
if (_MacIsDecZ(pSrc)) {
_MacDCopy(pDst,&decPiOver2);
_MacRet(pDst);
}
(void) _MulDec80Bit(temp1= &dtemp1, nsrc, nsrc);
(void) _SubDec80Bit(temp2= &dtemp2, &decOne, temp1);
_SqrtDec80Bit(temp3=&dtemp3, temp2);
if (_MacIsDecZ(temp3)) /* arcsin(1) = pi/2 */
{_MacDZero(pDst);}
else {
(void) _DivDec80Bit(temp4=&dtemp4, temp3, nsrc);
_ATanDec80Bit(pDst, temp4);
}
if (isn)
(void) _SubDec80Bit(pDst, &decPi, pDst);
/* reduce from 80-bit back to 64-bit */
(void) _Sq5UnsTo4Uns(pDst);
_MacRet(pDst);
}