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.4 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			79 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
| /* int	_Sq5UnsTo4Uns(pta);
 | |
|  *
 | |
|  * ARGUMENT
 | |
|  *	DEC	*pta;
 | |
|  *
 | |
|  * DESCRIPTION
 | |
|  *	This routine modifies the representation of a DEC to have an
 | |
|  *  approximately equivalent value with	an id <= MAXID and the mantissa
 | |
|  *  reduced to 64 bits,	if that	is possible.  The new DEC is stored in
 | |
|  *  same place as the old DEC.	Often this routine has no effect.
 | |
|  *
 | |
|  * SIDE	EFFECTS
 | |
|  *	pta is modified.
 | |
|  *
 | |
|  * RETURNS
 | |
|  *	GM_SUCCESS if the adjustment to	64 bits	is possible, and
 | |
|  *  GM_OVERFLOW	if it is not.
 | |
|  *
 | |
|  * AUTHOR
 | |
|  *  Jared Levy	 5/28/87
 | |
|  *   Copyright (C) 1987-1990 Greenleaf Software	Inc.  All rights reserved.
 | |
|  *
 | |
|  * MODIFICATIONS
 | |
|  *
 | |
|  */
 | |
| 
 | |
| #include <stdio.h>
 | |
| #include "gm.h"
 | |
| #include "gmsystem.h"
 | |
| 
 | |
| int	_Sq5UnsTo4Uns(pta)
 | |
| DEC	*pta;
 | |
| {
 | |
| 	SHORT		p=0, i;
 | |
| 	unsigned SHORT	r=0;
 | |
| 	unsigned SHORT	*a;
 | |
| 
 | |
| 	a = pta->dc.sl;
 | |
| 
 | |
| 	i = pta->dc.id;
 | |
| 
 | |
| 	if (i>GM_MAXID)	 {
 | |
| 		_DivUnsArrByPwrOf10(a, 5, i - GM_MAXID);
 | |
| 		i = GM_MAXID;
 | |
| 		}
 | |
| 
 | |
| 	if ((a[4] > 0) || (a[3]	> 32767))  {
 | |
| 	    if (a[4] >=	500)  {
 | |
| 		r = _DivUnsArrByUns(a, 10000, 5);
 | |
| 		p+=4;
 | |
| 		}
 | |
| 
 | |
| 	    if (a[4] >=	50)  {
 | |
| 		_DivUnsArrByUnsRound(a,	1000, 5);
 | |
| 		p+=3;
 | |
| 	    }
 | |
| 	    else
 | |
| 		if (a[4] >= 5)	{
 | |
| 			_DivUnsArrByUnsRound(a,	100, 5);
 | |
| 			p+=2;
 | |
| 		}
 | |
| 		else
 | |
| 			if ((a[4] > 0) || (a[3]	> 32767))  {
 | |
| 				_DivUnsArrByUnsRound(a,	10, 5);
 | |
| 				p++;
 | |
| 			}
 | |
| 			else
 | |
| 				if (r >= 5000)
 | |
| 					(void) _IncrementUnsArr(a);
 | |
| 	}
 | |
| 
 | |
| 	pta->dc.id = i-p;
 | |
| 
 | |
| 	if (i -	p < GM_MINID)
 | |
| 		return(GM_OVERFLOW);
 | |
| 
 | |
| 	return(GM_SUCCESS);
 | |
| }
 |