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
		
			
				
	
	
		
			58 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			58 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
/* void	_SinDecSmall(pDst,pSrc)
 | 
						|
 *
 | 
						|
 * ARGUMENT
 | 
						|
 *	DEC	*pDst, *pSrc;
 | 
						|
 *
 | 
						|
 * DESCRIPTION
 | 
						|
 *	Sets pDst = sin(pSrc), where 0 <= pSrc < pi / 4.
 | 
						|
 *
 | 
						|
 * SIDE	EFFECTS
 | 
						|
 *	None.
 | 
						|
 *
 | 
						|
 * RETURNS
 | 
						|
 *	None.
 | 
						|
 *
 | 
						|
 * ALGORITHM
 | 
						|
 *  Using the Taylor series,
 | 
						|
 *	sin(x) = x - x^3/3! + x^5/5! - ...
 | 
						|
 *
 | 
						|
 * AUTHOR
 | 
						|
 *  Jared Levy		April 7, 1987
 | 
						|
 *   Copyright (C) 1987-1990 Greenleaf Software	Inc.  All rights reserved.
 | 
						|
 *
 | 
						|
 * MODIFICATIONS
 | 
						|
 *
 | 
						|
 */
 | 
						|
 | 
						|
#include <stdio.h>
 | 
						|
#include "gm.h"
 | 
						|
#include "gmsystem.h"
 | 
						|
 | 
						|
void	_SinDecSmall(pDst,pSrc)
 | 
						|
DEC	*pDst, *pSrc;
 | 
						|
{
 | 
						|
	DEC	*srcsq,	dsrcsq,	*term, dterm, *fact, dfact;
 | 
						|
	int	i;
 | 
						|
 | 
						|
	srcsq =	&dsrcsq;
 | 
						|
	(void) _MulDec80Bit(srcsq, pSrc, pSrc);
 | 
						|
	_MacDCopy(pDst,	pSrc);
 | 
						|
	fact = ConvLongToDecimal(&dfact, 6L);
 | 
						|
	term = &dterm;
 | 
						|
	(void) _MulDec80Bit(term, srcsq, pSrc);
 | 
						|
	(void) _DivRndDec80Bit(term, term, fact, 23);
 | 
						|
	i = 3;
 | 
						|
	while (!(_MacIsDecZ(term)))  {
 | 
						|
		if ((i % 4) == 1)
 | 
						|
			(void) _AddDec80Bit(pDst, pDst,	term);
 | 
						|
		else
 | 
						|
			(void) _SubDec80Bit(pDst, pDst,	term);
 | 
						|
		i+=2;
 | 
						|
		_MulDec80Bit(term, term, srcsq);
 | 
						|
		fact->dc.sl[0] = i * (i	- 1);
 | 
						|
		_DivRndDec80Bit(term, term, fact, 23);
 | 
						|
		}
 | 
						|
 | 
						|
}
 | 
						|
 |