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
		
			
				
	
	
		
			68 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			68 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
| /* long	ConvDecimalToDollarsAndCents(pc, x )
 | |
|  *
 | |
|  * ARGUMENT
 | |
|  *	DEC	*x;	input DEC
 | |
|  *	int	*pc;	place to store cents
 | |
|  *
 | |
|  * DESCRIPTION
 | |
|  *	Converts DEC to	dollars	and cents.
 | |
|  *  The	number of cents	is stored in *pc,
 | |
|  *  while the number of	dollars	is returned.
 | |
|  *
 | |
|  * SIDE	EFFECTS
 | |
|  *	None.
 | |
|  *
 | |
|  * RETURNS
 | |
|  *	The number of dollars if the conversion	is successful,
 | |
|  *  and	0 otherwise.
 | |
|  *
 | |
|  * POSSIBLE ERROR CODES
 | |
|  *	GM_NULLPOINTER
 | |
|  *	GM_OVERFLOW
 | |
|  *
 | |
|  * AUTHOR
 | |
|  *   Jared Levy		Oct. 10, 1989
 | |
|  *   Copyright (C) 1989-1990 Greenleaf Software	Inc.  All rights reserved.
 | |
|  *
 | |
|  * MODIFICATIONS
 | |
|  *
 | |
|  */
 | |
| 
 | |
| #include <stdio.h>
 | |
| #include "gmsystem.h"
 | |
| 
 | |
| long	ConvDecimalToDollarsAndCents(pc, x )
 | |
| DEC	*x;
 | |
| int	*pc;
 | |
| {
 | |
| 	long	d;
 | |
| 	DEC	dxc, *xc=&dxc;
 | |
| 
 | |
| 	_MacStart(GM_DTODC);
 | |
| 	_MacInVar(x, 0L);
 | |
| 	if (!pc)  {
 | |
| 		_MacErr(GM_NULLPOINTER);
 | |
| 		_MacRet(0);
 | |
| 	}
 | |
| 
 | |
| 	_ScaleDec80Bit(xc, x, 2);
 | |
| 
 | |
| 	if (!xc->ls.lsl[1] && !(xc->ls.lsl[0] &	0x80000000L))  {
 | |
| 		d = xc->ls.lsl[0]/100L;
 | |
| 		*pc = (int) (xc->ls.lsl[0] - d * 100L);
 | |
| 	}
 | |
| 	else  {
 | |
| 		*pc = _DivUnsArrByUns(xc->dc.sl, 100, 5);
 | |
| 		if (xc->ls.lsl[1] || (xc->ls.lsl[0] & 0x80000000L))  {
 | |
| 			_MacErr(GM_OVERFLOW);
 | |
| 			_MacRet(0L);
 | |
| 		}
 | |
| 		d = xc->ls.lsl[0];
 | |
| 	}
 | |
| 
 | |
| 	if (_MacIsDecN(xc))
 | |
| 		d = -d;
 | |
| 
 | |
| 	_MacRet(d);
 | |
| }
 |