2002-02-26 12:19:02 +00:00
|
|
|
/* unsigned _DivUnsArrByUns(a,c,n)
|
|
|
|
*
|
|
|
|
* ARGUMENT
|
|
|
|
* unsigned a[];
|
|
|
|
* unsigned c; number of divide by
|
|
|
|
* int n; number of digits
|
|
|
|
*
|
|
|
|
* DESCRIPTION
|
|
|
|
* Divides a number of n digits (a) by c and stores the result in a.
|
|
|
|
* The remainder is calculated and returnes.
|
|
|
|
*
|
|
|
|
* SIDE EFFECTS
|
|
|
|
* None.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Remainder.
|
|
|
|
*
|
|
|
|
* AUTHOR
|
|
|
|
* Brugnoli Giugno 1992
|
2004-03-09 09:49:17 +00:00
|
|
|
* Bonazzi Febbraio 2002
|
2002-02-26 12:19:02 +00:00
|
|
|
*
|
|
|
|
* MODIFICATIONS
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "gm.h"
|
|
|
|
#include "gmsystem.h"
|
|
|
|
|
|
|
|
unsigned _DivUnsArrByUns(a,c,n)
|
|
|
|
unsigned SHORT a[],c;
|
|
|
|
int n;
|
|
|
|
{
|
|
|
|
int i;
|
2004-03-09 09:49:17 +00:00
|
|
|
unsigned SHORT rem = 0,qt;
|
2002-02-26 12:19:02 +00:00
|
|
|
unsigned long remup,ntbd;
|
|
|
|
|
2004-03-09 09:49:17 +00:00
|
|
|
if ((c) && (n))
|
|
|
|
{
|
|
|
|
for (i = n-1; i >= 0;i--)
|
2002-02-26 12:19:02 +00:00
|
|
|
{
|
2004-03-09 09:49:17 +00:00
|
|
|
remup = (long)rem << BITSPERUI;
|
|
|
|
ntbd = (long)a[i] + remup;
|
|
|
|
qt = (unsigned SHORT)(ntbd / c);
|
|
|
|
rem = (unsigned SHORT)(ntbd % c);
|
|
|
|
a[i] = qt;
|
2002-02-26 12:19:02 +00:00
|
|
|
}
|
2004-03-09 09:49:17 +00:00
|
|
|
}
|
|
|
|
return(rem);
|
2002-02-26 12:19:02 +00:00
|
|
|
}
|