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
		
			
				
	
	
		
			102 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			102 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
/* DEC	*RootDecimal(pDst,pSrc1,pSrc2)
 | 
						|
 *
 | 
						|
 * ARGUMENT
 | 
						|
 *	DEC	*pDst,*pSrc1,*pSrc2;
 | 
						|
 *
 | 
						|
 * DESCRIPTION
 | 
						|
 *	Calculates the pSrc2 root of pSrc1 and returns the answer in pDst.
 | 
						|
 *  This provides an x**(1/y) power function for DEC numbers.
 | 
						|
 *
 | 
						|
 * SIDE	EFFECTS
 | 
						|
 *	None.
 | 
						|
 *
 | 
						|
 * RETURNS
 | 
						|
 *	Pointer	to the result if no error, otherwise GM_NULL.
 | 
						|
 *
 | 
						|
 * ALGORITHM:
 | 
						|
 *	x**y = e**(ln(x)/y). Therefore,	call dlnx() to get the natural log
 | 
						|
 *  and	then multiply by the power of x.  Finally, call	dexx() to provide
 | 
						|
 *  e**z.
 | 
						|
 *
 | 
						|
 * POSSIBLE ERROR CODES
 | 
						|
 *
 | 
						|
 *	GM_NULLPOINTER
 | 
						|
 *	GM_OVERFLOW
 | 
						|
 *	GM_UNDERFLOW
 | 
						|
 *	GM_IMAG
 | 
						|
 *	GM_PWR0
 | 
						|
 *	GM_DIV0
 | 
						|
 *
 | 
						|
 * AUTHOR
 | 
						|
 *  Andy Anderson   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"
 | 
						|
 | 
						|
DEC	*RootDecimal(pDst,pSrc1,pSrc2)
 | 
						|
DEC	*pDst, *pSrc1, *pSrc2;
 | 
						|
{
 | 
						|
	DEC	temp, *pt;
 | 
						|
	int	i;
 | 
						|
 | 
						|
	_MacStart(GM_DROOT);
 | 
						|
	_MacInVarD(pSrc1);
 | 
						|
	_MacInVarD(pSrc2);
 | 
						|
	_MacOutVarD(pDst);
 | 
						|
 | 
						|
	if (_MacIsDecN(pSrc1))	{
 | 
						|
		_MacErr(GM_IMAG);
 | 
						|
		_MacRet(GM_NULL);
 | 
						|
	}
 | 
						|
 | 
						|
	if (_MacIsDecZ(pSrc2))	{
 | 
						|
		_MacErr(GM_DIV0);
 | 
						|
		_MacRet(GM_NULL);
 | 
						|
	}
 | 
						|
 | 
						|
	if (_MacIsDecZ(pSrc1))	{
 | 
						|
		if (_MacIsDecP(pSrc2))	{
 | 
						|
			_MacDZero(pDst);
 | 
						|
			_MacRet(pDst);
 | 
						|
		}
 | 
						|
		else  {
 | 
						|
			_MacErr(GM_PWR0);
 | 
						|
			_MacRet(GM_NULL);
 | 
						|
		}
 | 
						|
	}
 | 
						|
 | 
						|
	pt = &temp;
 | 
						|
 | 
						|
	(void) _LnDec80Bit(pt, pSrc1);
 | 
						|
	i = _DivDec80Bit(pt, pt, pSrc2);
 | 
						|
	if(i!=GM_SUCCESS) {
 | 
						|
		_MacErr(i);
 | 
						|
		_MacRet(GM_NULL);
 | 
						|
	}
 | 
						|
 | 
						|
	i = _ExpDec80Bit(pt, pt);
 | 
						|
	if(i==GM_OVERFLOW) {
 | 
						|
		_MacErr(GM_OVERFLOW);
 | 
						|
		_MacRet(GM_NULL);
 | 
						|
	}
 | 
						|
 | 
						|
	i = _Sq5UnsTo4Uns(pt);
 | 
						|
	if(i!=GM_SUCCESS) {
 | 
						|
		_MacErr(GM_OVERFLOW);
 | 
						|
		_MacRet(GM_NULL);
 | 
						|
	}
 | 
						|
 | 
						|
	if (_MacIsDecZ(pt))  {
 | 
						|
		_MacErr(GM_UNDERFLOW);
 | 
						|
	}
 | 
						|
 | 
						|
	_MacDCopy(pDst,pt);
 | 
						|
	_MacRet(pDst);
 | 
						|
}
 |