Files correlati :gfm.dll Ricompilazione Demo : [ ] Commento :riportate sulla 2.1 le correzioni sulla gfm.dll della 2.0 git-svn-id: svn://10.65.10.50/trunk@11815 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			88 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			88 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
| /* int _MulUnsArrByPwrOf10(pa,n,w)
 | |
|  *
 | |
|  * ARGUMENT
 | |
|  *      unsigned        pa[];
 | |
|  *      int             n;            power of 10 to multiply by
 | |
|  *      int             w;            number of digits
 | |
|  *
 | |
|  * DESCRIPTION
 | |
|  *      Multiplies the pa[] array by 10^n (0<n<47),
 | |
|  *
 | |
|  * SIDE EFFECTS
 | |
|  *      The value of pa is unchanged on overflow.
 | |
|  *
 | |
|  * RETURNS
 | |
|  *      GM_SUCCES if no overflow, otherwise GM_OVERFLOW
 | |
|  *
 | |
|  * AUTHOR
 | |
|  *      Brugnoli Giugno 1992
 | |
|  *
 | |
|  * MODIFICATIONS
 | |
|  *
 | |
|  */
 | |
| 
 | |
| #include <stdio.h>
 | |
| #include <math.h>
 | |
| #include "gm.h"
 | |
| #include "gmsystem.h"
 | |
| 
 | |
| int Multiply(sr,num,m)
 | |
| unsigned SHORT  sr[],num;
 | |
| int       m;
 | |
| {
 | |
|   int i;
 | |
|   unsigned long pdst[10];
 | |
|   unsigned SHORT carry = 0;
 | |
| 
 | |
|   for (i=0;i<m;i++)
 | |
|     pdst[i]=(unsigned long)sr[i]*num;
 | |
| 
 | |
|   for (i=0;i<m;i++)
 | |
|   {
 | |
|     pdst[i]+=carry;
 | |
|     if (pdst[i]>MAXUNSINT)
 | |
|     {
 | |
|       carry=(unsigned SHORT)(pdst[i]>>BITSPERUI);
 | |
|       sr[i]=(unsigned SHORT)(pdst[i]&MAXUNSINT);
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       carry=0;
 | |
|       sr[i]=(unsigned SHORT)pdst[i];
 | |
|     }
 | |
|   }
 | |
|   return( (carry)? GM_OVERFLOW : GM_SUCCESS );
 | |
| }
 | |
| 
 | |
| 
 | |
| int    _MulUnsArrByPwrOf10(pa,n,w)
 | |
| unsigned SHORT        pa[];
 | |
| int             n,w;
 | |
| {
 | |
|   int k=GM_SUCCESS;
 | |
| 
 | |
|   if (n>47)
 | |
|     return GM_OVERFLOW;
 | |
| 
 | |
|   while (n>4)
 | |
|   {
 | |
|     k = Multiply(pa,10000,w);
 | |
|     if (k != GM_SUCCESS)
 | |
|       return k;
 | |
|     n-=4;
 | |
|   }
 | |
| 
 | |
|   switch (n)
 | |
|   {
 | |
| 		case 0: k=Multiply(pa,1,w); break;
 | |
| 		case 1: k=Multiply(pa,10,w); break;
 | |
| 		case 2: k=Multiply(pa,100,w); break;
 | |
| 		case 3: k=Multiply(pa,1000,w); break;
 | |
| 		case 4: k=Multiply(pa,10000,w); break;
 | |
| 		default: break;
 | |
|   }
 | |
| 
 | |
|   return(k);
 | |
| 
 | |
| }
 |