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
		
			
				
	
	
		
			79 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			79 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
| /* DEC	*MultiplyDecimalAndTruncate(pDst,pSrc1,pSrc2,nid);
 | |
|  *
 | |
|  * ARGUMENT
 | |
|  *	DEC	*pDst;
 | |
|  *	DEC	*pSrc1,pSrc2;
 | |
|  *	int	nid;
 | |
|  *
 | |
|  * DESCRIPTION
 | |
|  *	Multiplies pSrc1 by pSrc2, storing the result in pDst.	The product is
 | |
|  *  calculated to nid decimal places.
 | |
|  *
 | |
|  * SIDE	EFFECTS
 | |
|  *	*pDst is indeterminate on overflow, underflow.
 | |
|  *
 | |
|  * RETURNS
 | |
|  *	Returns	pointer	to pDst	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_NOMEMORY
 | |
|  *	GM_INVALIDID
 | |
|  *	GM_OVERFLOW
 | |
|  *	GM_UNDERFLOW
 | |
|  *
 | |
|  * 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	*MultiplyDecimalAndTruncate(pDst,pSrc1,pSrc2,nid)
 | |
| DEC	*pDst;
 | |
| DEC	*pSrc1,*pSrc2;
 | |
| int	nid;
 | |
| {
 | |
| 	register int	i;
 | |
| 
 | |
| 	_MacStart(GM_DMULT);
 | |
| 
 | |
| 	if ((nid<GM_MINID)||(nid>GM_MAXID))  {
 | |
| 		_MacErr(GM_INVALIDID);
 | |
| 		_MacRet(GM_NULL);
 | |
| 	}
 | |
| 
 | |
| 	if (!MultiplyDecimal(pDst, pSrc1, pSrc2))
 | |
| 		_MacRet(GM_NULL);
 | |
| 
 | |
| 	if (_MacIsDecZ(pDst))  {
 | |
| 		pDst->dc.id = nid;
 | |
| 		_MacRet(pDst);
 | |
| 	}
 | |
| 
 | |
| 	i = _TruncateDec80Bit(pDst, pDst, nid);
 | |
| 
 | |
| /*  check if number can	fit into 64 bits (no shifting allowed) */
 | |
| 	if (!((pDst->dc.msd == 0)  && (pDst->dc.sl[3] <	 32768L)))
 | |
| 	      i	= GM_OVERFLOW;
 | |
| 
 | |
| 	if (i != GM_SUCCESS)  {
 | |
| 		_MacErr(i);
 | |
| 		_MacRet(GM_NULL);
 | |
| 		}
 | |
| 
 | |
| 	if (_MacIsDecZ(pDst))
 | |
| 		_MacErr(GM_UNDERFLOW);
 | |
| 
 | |
| 	_MacRet(pDst);
 | |
| 
 | |
| }
 |