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
		
			
				
	
	
		
			60 lines
		
	
	
		
			970 B
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			60 lines
		
	
	
		
			970 B
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
/* unsigned	ConvDecimalToUns(x)
 | 
						|
 *
 | 
						|
 * ARGUMENT
 | 
						|
 *	DEC	*x;
 | 
						|
 *
 | 
						|
 * DESCRIPTION
 | 
						|
 *	Converts a DEC to an unsigned (integer).
 | 
						|
 *
 | 
						|
 * SIDE	EFFECTS
 | 
						|
 *	None.
 | 
						|
 *
 | 
						|
 * RETURNS
 | 
						|
 *	The integer if the conversion is successful, and the error code
 | 
						|
 * otherwise.
 | 
						|
 *
 | 
						|
 * AUTHOR
 | 
						|
 *  Jared Levy	Feb. 9,	1987
 | 
						|
 *   Copyright (C) 1987-1990 Greenleaf Software	Inc.  All rights reserved.
 | 
						|
 *
 | 
						|
 * POSSIBLE ERROR CODES
 | 
						|
 *
 | 
						|
 *	GM_NULLPOINTER
 | 
						|
 *	GM_CNVRE
 | 
						|
 *	GM_CNVRW
 | 
						|
 *
 | 
						|
 * MODIFICATIONS
 | 
						|
 *
 | 
						|
 */
 | 
						|
 | 
						|
#include <stdio.h>
 | 
						|
#include "gm.h"
 | 
						|
#include "gmsystem.h"
 | 
						|
 | 
						|
unsigned	ConvDecimalToUns(x)
 | 
						|
DEC	*x;
 | 
						|
{
 | 
						|
	DEC		temp;
 | 
						|
	DEC		*pt;
 | 
						|
	unsigned SHORT	i;
 | 
						|
 | 
						|
	_MacStart(GM_DTOUI);
 | 
						|
	_MacInVar(x, 0);
 | 
						|
 | 
						|
	pt = &temp;
 | 
						|
	(void) _ScaleDec80Bit(pt, x, 0); /* convert to integer */
 | 
						|
 | 
						|
/* 0 <=	x <= 65535 */
 | 
						|
	if(!(pt->dc.sl[1] | pt->dc.sl[2] | pt->dc.sl[3]	| pt->dc.msd)
 | 
						|
		&& !_MacIsDecN(pt)) {
 | 
						|
			if (CompareDecimal(x,pt)!=0)
 | 
						|
				_MacErr(GM_CNVRW);
 | 
						|
			i = pt->dc.sl[0];
 | 
						|
			_MacRet	(i);
 | 
						|
			}
 | 
						|
 | 
						|
/* overflow */
 | 
						|
	_MacErr(GM_CNVRE);
 | 
						|
	_MacRet(0);
 | 
						|
}
 |