Files correlati : ve6.exe Ricompilazione Demo : [ ] Commento : Riportata la versione 3.1 patch 979 git-svn-id: svn://10.65.10.50/trunk@15623 c028cbd2-c16b-5b4b-a496-9718f37d4682
66 lines
1.1 KiB
C
Executable File
66 lines
1.1 KiB
C
Executable File
/* void _DivUnsArrByUnsRound(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 quotient is rounded to the nearest integer.
|
|
*
|
|
* SIDE EFFECTS
|
|
* None.
|
|
*
|
|
* RETURNS
|
|
* None.
|
|
*
|
|
* AUTHOR
|
|
* Brugnoli Giugno 1992
|
|
*
|
|
* MODIFICATIONS
|
|
*
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include "gm.h"
|
|
#include "gmsystem.h"
|
|
|
|
void _DivUnsArrByUnsRound(a,c,n)
|
|
unsigned SHORT a[],c;
|
|
int n;
|
|
{
|
|
int i;
|
|
unsigned SHORT rem,qt;
|
|
unsigned long remup,ntbd;
|
|
float limit;
|
|
|
|
rem=0;
|
|
|
|
if ((c)&&(n))
|
|
{
|
|
for (i=n-1;i>=0;i--)
|
|
{
|
|
remup=(long)rem<<BITSPERUI;
|
|
ntbd=(long)a[i]+remup;
|
|
qt=(unsigned SHORT)(ntbd / c);
|
|
rem=(unsigned SHORT)(ntbd % c);
|
|
a[i]=qt;
|
|
}
|
|
limit=(float)(c-1)/2;
|
|
if (rem>limit)
|
|
{
|
|
if (a[0] == 0xFFFF)
|
|
{
|
|
unsigned SHORT b[5] = {1, 0, 0, 0, 0};
|
|
if (n < 1 || n > 5)
|
|
_MacErr(GM_INVALIDID);
|
|
else
|
|
_AddUnsArrToUnsArr( a, b, a, n);
|
|
}
|
|
else
|
|
a[0]++;
|
|
}
|
|
}
|
|
}
|