3d88151f4d
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
100 lines
1.8 KiB
C
Executable File
100 lines
1.8 KiB
C
Executable File
/* int _MulUnsArrP10AndAddInt(pa,c)
|
|
*
|
|
* ARGUMENT
|
|
* unsigned pa[];
|
|
* int c; # to add after mult by 10
|
|
*
|
|
* DESCRIPTION
|
|
* Multiplies the number (<=80bits) in the int array by decimal 10
|
|
* and adds 'c' to it. Used in the divide routines for adjusting,
|
|
*
|
|
* 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 Mltply(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)||(sr[m-1]>>(BITSPERUI-1)))? GM_OVERFLOW : GM_SUCCESS );
|
|
}
|
|
|
|
|
|
int _MulUnsArrP10AndAddInt(pa,c)
|
|
unsigned SHORT pa[];
|
|
int c;
|
|
{
|
|
|
|
int ppdf = 10, i;
|
|
unsigned long pdst, carry = c;
|
|
unsigned SHORT dst[10];
|
|
|
|
for (i=0;i<=4;i++)
|
|
dst[i] = pa[i];
|
|
for (i=5;i<=9;i++)
|
|
dst[i] = 0;
|
|
|
|
if (Mltply(dst,ppdf,5) == GM_OVERFLOW)
|
|
return GM_OVERFLOW;
|
|
|
|
for (i = 0 ; carry && (i <= 9); i++)
|
|
{
|
|
pdst=(long)dst[i]+(long)carry;
|
|
if (pdst>MAXUNSINT)
|
|
{
|
|
carry=(pdst>>BITSPERUI);
|
|
dst[i]=(unsigned SHORT)(pdst&MAXUNSINT);
|
|
}
|
|
else
|
|
{
|
|
dst[i]=(unsigned SHORT)pdst;
|
|
carry=0;
|
|
}
|
|
}
|
|
|
|
if (i>5) // va bene o dovrebbe essere 4
|
|
return GM_OVERFLOW;
|
|
|
|
for (i=0;i<5;i++)
|
|
pa[i]=dst[i];
|
|
|
|
return(GM_SUCCESS);
|
|
|
|
}
|