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

73 lines
1.2 KiB
C
Executable File

/* int _DoubleUnsArr(a,n)
*
* ARGUMENT
* unsigned *a;
* int n;
*
* DESCRIPTION
* Multiplies a by 2 and stores the result in a.
*
*
* SIDE EFFECTS
*
*
* RETURNS
* SUCCESS if no overflow, otherwise FAILURE.
*
* AUTHOR
* Brugnoli Giugno 1992
*
* MODIFICATIONS
*
*/
#include <stdio.h>
#include <math.h>
#include "gm.h"
#include "gmsystem.h"
extern double pow(double, double);
void _DoubleUnsArr(a,n)
unsigned SHORT a[];
int n;
{
int i;
unsigned long maxunsint,pdst;
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++)
{
pdst=carry+(unsigned long)a[i]*2;
if (pdst>maxunsint)
{
carry=(unsigned SHORT)(pdst>> BITSPERUI );
a[i]=(unsigned SHORT)(pdst & maxunsint );
}
else
{
a[i]=(unsigned SHORT)pdst;
carry=0;
}
}
if ((a[n-1])>>(BITSPERUI-1))
{
return(FAILURE);
}
else
{
return(GM_SUCCESS);
}
}
}