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
		
			
				
	
	
		
			70 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			70 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
| /* int _MulUnsArrByPwrOf10Limited(pa,n,dig)
 | |
|  *
 | |
|  * ARGUMENT
 | |
|  *      unsigned        pa[];         points to a 160bit number
 | |
|  *      int             n;            power of 10 to multiply by (0..19)
 | |
|  *      int             dig;          number of digits to multiply
 | |
|  *
 | |
|  * DESCRIPTION
 | |
|  *      Multiplies the pa[] array by 10^n (0<n<19),
 | |
|  *  if the multiplication overflows, multiplies by largest power of 10
 | |
|  *  which doesn't generate overflow and return that power of ten.
 | |
|  *
 | |
|  * SIDE EFFECTS
 | |
|  *      None.
 | |
|  *
 | |
|  * RETURNS
 | |
|  *      Power of ten multiplied by.
 | |
|  *
 | |
|  * AUTHOR
 | |
|  *      Brugnoli Giugno 1992
 | |
|  *
 | |
|  * MODIFICATIONS
 | |
|  *
 | |
|  */
 | |
| 
 | |
| #include <stdio.h>
 | |
| #include "gm.h"
 | |
| #include "gmsystem.h"
 | |
| 
 | |
| 
 | |
| int    _MulUnsArrByPwrOf10Limited(pa,n,dig)
 | |
| unsigned SHORT        pa[];
 | |
| int             n,dig;
 | |
| {
 | |
| 
 | |
| int k,i,pow;
 | |
| unsigned SHORT cop[10];
 | |
| 
 | |
|   k=GM_SUCCESS;
 | |
|   pow=0;
 | |
| 
 | |
|   for (i=0;i<10;i++)
 | |
|     {
 | |
|     cop[i]=0;
 | |
|     }
 | |
| 
 | |
|   while((pow<n)&&(!k))
 | |
|     {
 | |
|     for (i=0;i<dig;i++)
 | |
|       {
 | |
|       cop[i]=pa[i];
 | |
|       }
 | |
|     k=_MulUnsArrByPwrOf10(pa,1,dig);
 | |
|     if (!k)
 | |
|       {
 | |
|       pow++;
 | |
|       }
 | |
|     }
 | |
| 
 | |
|   if (k)
 | |
|     {
 | |
|     for (i=0;i<dig;i++)
 | |
|       {
 | |
|       pa[i]=cop[i];
 | |
|       }
 | |
|     }
 | |
| 
 | |
|   return(pow);
 | |
| }
 |