alex ba237a9d91 Patch level : no patch
Files correlati     :
Ricompilazione Demo : [ ]
Commento            :
Aggiunti i sorgenti per Greenleaf Math Library (gfm.dll)


git-svn-id: svn://10.65.10.50/trunk@10079 c028cbd2-c16b-5b4b-a496-9718f37d4682
2002-02-26 12:19:02 +00:00

69 lines
1.3 KiB
C
Executable File

/* void _MulUnsArr(src1,dst,num,n)
*
* ARGUMENT
* unsigned *src1, *dst, num;
* unsigned n;
*
* DESCRIPTION
* Multiplies the number 'a' (of 'n' 16-bits ints) by num and places
* the result in dst. We assume that the caller has made sure there are
* enough ints to hold the result. We don't check for overflow!!!.
*
* SIDE EFFECTS
* Can't have more than 10 ints to multiply.
*
* RETURNS
* None.
*
* AUTHOR
* Brugnoli Giugno 1992
*
* MODIFICATIONS
*
*/
#include <stdio.h>
#include <math.h>
#include "gm.h"
#include "gmsystem.h"
extern double pow(double, double);
void _MulUnsArr(src1, dst, num, n)
unsigned SHORT src1[], dst[], num;
int n;
{
int i;
unsigned long pdst[10],maxunsint;
unsigned SHORT carry;
#ifdef SH_LIB
maxunsint=1;
for (i=1;i<=BITSPERUI;i++) maxunsint*=2;
maxunsint--;
#else
maxunsint=(unsigned long)pow(2.,(float)BITSPERUI)-1;
#endif
carry=0;
for (i=0;i<n;i++)
{
pdst[i]=(unsigned long)src1[i]*num;
}
for (i=0;i<n;i++)
{
pdst[i]+=carry;
if (pdst[i]>maxunsint)
{
carry=(unsigned SHORT)(pdst[i]>>BITSPERUI);
dst[i]=(unsigned SHORT)(pdst[i]&maxunsint);
}
else
{
carry=0;
dst[i]=(unsigned SHORT)pdst[i];
}
}
}