2002-02-26 12:19:02 +00:00
|
|
|
/* int _DivUnsArrByPwrOf10(a,n,p)
|
|
|
|
*
|
|
|
|
* ARGUMENT
|
|
|
|
* unsigned a[];
|
|
|
|
* int p; power of 10 to divide by
|
|
|
|
* int n; number of digits
|
|
|
|
*
|
|
|
|
* DESCRIPTION
|
|
|
|
* Divides a number of n words (a) by a power of 10, c= a/10^p,
|
|
|
|
* a>=0, p>0, rounding the result, c is correct only if a/10^p<2^79.
|
|
|
|
*
|
|
|
|
* SIDE EFFECTS
|
|
|
|
* The value of a is destroyed.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* None. (always succeeds)
|
|
|
|
*
|
|
|
|
* AUTHOR
|
|
|
|
* Brugnoli Giugno 1992
|
|
|
|
*
|
|
|
|
* MODIFICATIONS
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include "gm.h"
|
|
|
|
#include "gmsystem.h"
|
|
|
|
|
|
|
|
void _DivUnsArrByPwrOf10(a,n,p)
|
|
|
|
unsigned SHORT a[];
|
|
|
|
int n,p;
|
|
|
|
{
|
|
|
|
while (p>4)
|
2004-03-09 09:49:17 +00:00
|
|
|
{
|
2002-02-26 12:19:02 +00:00
|
|
|
_DivUnsArrByUns(a,10000,n);
|
|
|
|
p-=4;
|
2004-03-09 09:49:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (p)
|
|
|
|
{
|
|
|
|
case 0: _DivUnsArrByUnsRound(a,1,n); break;
|
|
|
|
case 1: _DivUnsArrByUnsRound(a,10,n); break;
|
|
|
|
case 2: _DivUnsArrByUnsRound(a,100,n); break;
|
|
|
|
case 3: _DivUnsArrByUnsRound(a,1000,n); break;
|
|
|
|
case 4: _DivUnsArrByUnsRound(a,10000,n); break;
|
|
|
|
default: break;
|
|
|
|
}
|
2002-02-26 12:19:02 +00:00
|
|
|
}
|