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
		
			
				
	
	
		
			64 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			64 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
/* DEC	*ConvDollarsAndCentsToDecimal( x, d, c)
 | 
						|
 *
 | 
						|
 * ARGUMENT
 | 
						|
 *	DEC	*x;	output
 | 
						|
 *	long	l;	dollars
 | 
						|
 *	int	c;	cents
 | 
						|
 *
 | 
						|
 * DESCRIPTION
 | 
						|
 *	Converts d dollars and c cents to a DEC	with implied decimal 2.
 | 
						|
 *
 | 
						|
 * SIDE	EFFECTS
 | 
						|
 *	x is indeterminate on error.
 | 
						|
 *
 | 
						|
 * RETURNS
 | 
						|
 *	The DEC	if the conversion is successful, and GM_NULL otherwise.
 | 
						|
 *
 | 
						|
 * POSSIBLE ERROR CODES
 | 
						|
 *	GM_NULLPOINTER
 | 
						|
 *
 | 
						|
 * AUTHOR
 | 
						|
 *   Jared Levy		Oct. 10, 1989
 | 
						|
 *   Copyright (C) 1988-1990 Greenleaf Software	Inc.  All rights reserved.
 | 
						|
 *
 | 
						|
 * MODIFICATIONS
 | 
						|
 *
 | 
						|
 */
 | 
						|
 | 
						|
#include <stdio.h>
 | 
						|
#include "gmsystem.h"
 | 
						|
 | 
						|
DEC	*ConvDollarsAndCentsToDecimal( x, d, c)
 | 
						|
DEC	*x;
 | 
						|
long	d;
 | 
						|
int	c;
 | 
						|
{
 | 
						|
	int	isneg=0;
 | 
						|
 | 
						|
	_MacStart(GM_DCTOD);
 | 
						|
	_MacOutVarD(x);
 | 
						|
 | 
						|
	if (d<0)  {
 | 
						|
		isneg =	1;
 | 
						|
		d = -d;
 | 
						|
		c = (c<0) ? -c : c;
 | 
						|
	}
 | 
						|
 | 
						|
	x->ls.lmsd = 0;
 | 
						|
	x->ls.lsl[1] = 0L;
 | 
						|
	if (d<=21470000L)
 | 
						|
		x->ls.lsl[0] = d * 100L	+ (long) c;
 | 
						|
	else  {
 | 
						|
		x->ls.lsl[0] = d;
 | 
						|
		_MulUnsArrByPwrOf10(x->dc.sl, 2, 3);
 | 
						|
		x->ls.lsl[0] +=	(long) c;
 | 
						|
		if (x->ls.lsl[0] < (unsigned long) c &&	c>0)
 | 
						|
			x->ls.lsl[1]--;
 | 
						|
	}
 | 
						|
 | 
						|
	x->ls.lid = 2;
 | 
						|
	x->ls.lattr = isneg;
 | 
						|
 | 
						|
	_MacRet(x);
 | 
						|
}
 |