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
		
			
				
	
	
		
			75 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			75 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
/* DEC	*DivideDecimalAndTruncate(dst,src1,src2,nid);
 | 
						|
 *
 | 
						|
 * ARGUMENT
 | 
						|
 *	DEC	*dst;
 | 
						|
 *	DEC	*src1,*src2;
 | 
						|
 *	int	nid;
 | 
						|
 *
 | 
						|
 * DESCRIPTION
 | 
						|
 *	Divides	src1 by	src2, storing the result in dst.  The quotient is
 | 
						|
 *  calculated to nid decimal places.
 | 
						|
 *
 | 
						|
 * RETURNS
 | 
						|
 *	Returns	pointer	to dst if successful, otherwise	a GM_NULL. The
 | 
						|
 *   type error	(GM_OVERFLOW, GM_UNDERFLOW, GM_NOMEMORY) is in wGMError
 | 
						|
 *   if	wGMError doesn't contain a previous error.
 | 
						|
 *
 | 
						|
 * POSSIBLE ERROR CODES
 | 
						|
 *
 | 
						|
 *	GM_NULLPOINTER
 | 
						|
 *	GM_OVERFLOW
 | 
						|
 *	GM_UNDERFLOW
 | 
						|
 *	GM_DIV0
 | 
						|
 *	GM_INVALIDID
 | 
						|
 *
 | 
						|
 * AUTHOR
 | 
						|
 *  Jared Levy	 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	*DivideDecimalAndTruncate(dst,src1,src2,nid)
 | 
						|
DEC	*dst;
 | 
						|
DEC	*src1,*src2;
 | 
						|
int	nid;
 | 
						|
{
 | 
						|
	int	i;
 | 
						|
 | 
						|
	_MacStart(GM_DDIVT);
 | 
						|
	_MacInVarD(src1);
 | 
						|
	_MacInVarD(src2);
 | 
						|
	_MacOutVarD(dst);
 | 
						|
 | 
						|
	if ((nid > GM_MAXID) ||	(nid < GM_MINID)){
 | 
						|
		_MacErr(GM_INVALIDID);
 | 
						|
		_MacRet	(GM_NULL);
 | 
						|
	}
 | 
						|
 | 
						|
	if (_MacIsDecZ(src2))  {
 | 
						|
		_MacErr(GM_DIV0);
 | 
						|
		_MacRet(GM_NULL);
 | 
						|
	}
 | 
						|
 | 
						|
	i = _DivTrnDec80Bit(dst, src1, src2, nid);
 | 
						|
 | 
						|
/*  check if number can	fit into 64 bits (no shifting allowed) */
 | 
						|
	if (!((dst->dc.msd == 0)  && (dst->dc.sl[3] < 32768L)))
 | 
						|
	      i	= GM_OVERFLOW;
 | 
						|
 | 
						|
	if (i != GM_SUCCESS)  {
 | 
						|
		_MacErr(i);
 | 
						|
		if (i != GM_UNDERFLOW)	{
 | 
						|
			_MacRet(GM_NULL);
 | 
						|
			}
 | 
						|
		}
 | 
						|
 | 
						|
	_MacRet(dst);
 | 
						|
 | 
						|
}
 |