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

67 lines
1.2 KiB
C
Executable File

/* void _SubUnsArr(src1,src2,n)
*
* ARGUMENT
* unsigned *src1, *src2;
* int n;
*
* DESCRIPTION
* Subtracts src2 from src1 putting the result in src1. It's assumed
* that caller has checked to assure that src1>src2 so no borrow can ever
* be generate (that's why this is a void!!).
*
* SIDE EFFECTS
* The original value of src1 is destroyed.
*
* 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 _SubUnsArr(src1, src2, n)
unsigned SHORT src1[], src2[];
int n;
{
int i;
unsigned long psrc,maxunsint;
unsigned SHORT carry;
carry=0;
#ifdef SH_LIB
maxunsint=1;
for (i=1;i<=BITSPERUI;i++) maxunsint*=2;
maxunsint--;
#else
maxunsint=(unsigned long)pow(2.,(float)BITSPERUI)-1;
#endif
if (n>0)
{
for (i=0;i<n;i++)
{
if (src2[i]>src1[i])
{
psrc=maxunsint+0x1L+(long)src1[i]-(long)carry;
carry=1;
}
else
{
psrc=src1[i]-carry;
carry=0;
}
src1[i]=(unsigned SHORT)(psrc-(unsigned long)src2[i]);
}
}
}