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
62 lines
1.1 KiB
C
Executable File
62 lines
1.1 KiB
C
Executable File
/* int _AddUnsArrToUnsArr(src1,src2,dst,n)
|
|
*
|
|
* ARGUMENT
|
|
* unsigned *src1, *src2, *dst;
|
|
* unsigned n;
|
|
*
|
|
* DESCRIPTION
|
|
* Adds src1 to src2 giving dst. src1 and src2 are unchanged.
|
|
* Src1, src2 and dst point to unsigned arrays.
|
|
*
|
|
* SIDE EFFECTS
|
|
*
|
|
*
|
|
* RETURNS
|
|
* GM_SUCCESS if no overflow, otherwise GM_FAILURE.
|
|
*
|
|
* AUTHOR
|
|
* Brugnoli Giugno 1992
|
|
*
|
|
* MODIFICATIONS
|
|
*
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <math.h>
|
|
#include "gm.h"
|
|
#include "gmsystem.h"
|
|
|
|
int _AddUnsArrToUnsArr(src1, src2, dst, n)
|
|
unsigned SHORT src1[], src2[], dst[];
|
|
int n;
|
|
{
|
|
int i;
|
|
unsigned long pdst;
|
|
unsigned carry = 0;
|
|
|
|
if (n>0)
|
|
{
|
|
for (i=0;i<n;i++)
|
|
{
|
|
pdst=carry+(unsigned long)src1[i];
|
|
pdst+=(unsigned long)src2[i];
|
|
if (pdst>MAXUNSINT)
|
|
{
|
|
carry=(unsigned)(pdst >> BITSPERUI );
|
|
dst[i]=(unsigned SHORT )(pdst & MAXUNSINT );
|
|
}
|
|
else
|
|
{
|
|
carry=0;
|
|
dst[i]=(unsigned SHORT)pdst;
|
|
}
|
|
}
|
|
|
|
if (dst[n-1]>>(BITSPERUI-1))
|
|
return(GM_FAILURE);
|
|
}
|
|
|
|
return(GM_SUCCESS);
|
|
}
|
|
|