Patch level :2.1 nopatch
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
This commit is contained in:
parent
ac70ddd888
commit
3d88151f4d
19
gfm/agmn.c
19
gfm/agmn.c
@ -26,24 +26,13 @@
|
||||
#include "gm.h"
|
||||
#include "gmsystem.h"
|
||||
|
||||
extern double pow(double, double);
|
||||
|
||||
int _AddUnsArrToUnsArr(src1, src2, dst, n)
|
||||
unsigned SHORT src1[], src2[], dst[];
|
||||
int n;
|
||||
{
|
||||
int i;
|
||||
unsigned long pdst,maxunsint;
|
||||
unsigned carry;
|
||||
|
||||
carry=0;
|
||||
#ifdef SH_LIB
|
||||
maxunsint=1;
|
||||
for (i=1;i<=BITSPERUI;i++) maxunsint*=2;
|
||||
maxunsint--;
|
||||
#else
|
||||
maxunsint=(unsigned long)pow(2.,(double)BITSPERUI)-1;
|
||||
#endif
|
||||
unsigned long pdst;
|
||||
unsigned carry = 0;
|
||||
|
||||
if (n>0)
|
||||
{
|
||||
@ -51,10 +40,10 @@ int n;
|
||||
{
|
||||
pdst=carry+(unsigned long)src1[i];
|
||||
pdst+=(unsigned long)src2[i];
|
||||
if (pdst>maxunsint)
|
||||
if (pdst>MAXUNSINT)
|
||||
{
|
||||
carry=(unsigned)(pdst >> BITSPERUI );
|
||||
dst[i]=(unsigned SHORT )(pdst & maxunsint );
|
||||
dst[i]=(unsigned SHORT )(pdst & MAXUNSINT );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
25
gfm/dmby1.c
25
gfm/dmby1.c
@ -17,6 +17,7 @@
|
||||
*
|
||||
* AUTHOR
|
||||
* Brugnoli Giugno 1992
|
||||
* Bonazzi Febbraio 2002
|
||||
*
|
||||
* MODIFICATIONS
|
||||
*
|
||||
@ -31,21 +32,19 @@ unsigned SHORT a[],c;
|
||||
int n;
|
||||
{
|
||||
int i;
|
||||
unsigned SHORT rem,qt;
|
||||
unsigned SHORT rem = 0,qt;
|
||||
unsigned long remup,ntbd;
|
||||
|
||||
rem=0;
|
||||
|
||||
if ((c)&&(n))
|
||||
if ((c) && (n))
|
||||
{
|
||||
for (i = n-1; i >= 0;i--)
|
||||
{
|
||||
for (i=n-1;i>=0;i--)
|
||||
{
|
||||
remup=(long)rem<<BITSPERUI;
|
||||
ntbd=(long)a[i]+remup;
|
||||
qt=(unsigned SHORT)(ntbd / c);
|
||||
rem=(unsigned SHORT)(ntbd % c);
|
||||
a[i]=qt;
|
||||
}
|
||||
remup = (long)rem << BITSPERUI;
|
||||
ntbd = (long)a[i] + remup;
|
||||
qt = (unsigned SHORT)(ntbd / c);
|
||||
rem = (unsigned SHORT)(ntbd % c);
|
||||
a[i] = qt;
|
||||
}
|
||||
return(rem);
|
||||
}
|
||||
return(rem);
|
||||
}
|
||||
|
81
gfm/dmbyn.c
81
gfm/dmbyn.c
@ -29,100 +29,81 @@
|
||||
#include "gm.h"
|
||||
#include "gmsystem.h"
|
||||
|
||||
extern double pow(double, double);
|
||||
|
||||
void _DivUnsArrByUnsArr(c,a,m,b,n,rf)
|
||||
unsigned SHORT a[],c[],b[];
|
||||
int n,m,rf;
|
||||
{
|
||||
int i,j,k,nc,ft = 0;
|
||||
unsigned long maxunsint,dvd,pqt,pp;
|
||||
unsigned long dvd,pqt,pp;
|
||||
float nqt;
|
||||
unsigned SHORT copa[10],copb[10],af[10],ppt[10],ppd[10],pqa[2];
|
||||
|
||||
#ifdef SH_LIB
|
||||
maxunsint=1;
|
||||
for (i=1;i<=BITSPERUI;i++) maxunsint*=2;
|
||||
maxunsint--;
|
||||
#else
|
||||
maxunsint=(unsigned long)pow(2.,(double)BITSPERUI)-1;
|
||||
#endif
|
||||
|
||||
|
||||
for(j=0;j<10;j++)
|
||||
{
|
||||
af[j]=copa[j]=copb[j]=0;
|
||||
}
|
||||
for(j=0;j<n;j++)
|
||||
{
|
||||
|
||||
for(j=0;j<n;j++)
|
||||
copb[j]=b[j];
|
||||
}
|
||||
for(j=0;j<m;j++)
|
||||
{
|
||||
|
||||
for(j=0;j<m;j++)
|
||||
copa[j]=a[j];
|
||||
}
|
||||
for(j=0;j<5;j++)
|
||||
{
|
||||
|
||||
for(j=0;j<5;j++)
|
||||
c[j]=0;
|
||||
}
|
||||
|
||||
|
||||
copa[m]=0;
|
||||
nc=m;
|
||||
af[0]=1;
|
||||
|
||||
for(i=m-n;i>=0;i--)
|
||||
{
|
||||
dvd=(long)copa[nc]*(maxunsint+1)+(long)copa[nc-1];
|
||||
{
|
||||
dvd=(long)copa[nc]*(MAXUNSINT+1)+(long)copa[nc-1];
|
||||
pqt=dvd/copb[n-1];
|
||||
pqa[1]=(unsigned SHORT)(pqt>>16);
|
||||
pqa[0]=(unsigned SHORT)(pqt&maxunsint);
|
||||
pqa[0]=(unsigned SHORT)(pqt&MAXUNSINT);
|
||||
for(j=0;j<10;j++)
|
||||
{
|
||||
ppd[j]=((j>n-1)?0:copb[j]);
|
||||
}
|
||||
for(j=1;j<=i;j++)
|
||||
{
|
||||
|
||||
for(j=1;j<=i;j++)
|
||||
{
|
||||
for(k=9;k>=1;k--)
|
||||
{
|
||||
ppd[k]=ppd[k-1];
|
||||
}
|
||||
ppd[0]=0;
|
||||
}
|
||||
|
||||
ppd[0]=0;
|
||||
}
|
||||
_MulUnsArrByUnsArr(ppd,pqa,ppt,10,2,ft);
|
||||
if (_CompareUnsArr(copa,ppt,nc+1)==-1)
|
||||
{
|
||||
pp=(long)ppt[nc]*(maxunsint+1)+(long)ppt[nc-1];
|
||||
{
|
||||
pp=(long)ppt[nc]*(MAXUNSINT+1)+(long)ppt[nc-1];
|
||||
nqt=(float)dvd;
|
||||
nqt/=(float)pp;
|
||||
nqt*=(float)pqt;
|
||||
nqt+=(float)5;
|
||||
#ifndef SH_LIB
|
||||
pqa[1]=(unsigned SHORT)((long int)nqt>>16);
|
||||
pqa[0]=(unsigned SHORT)((long int)nqt&maxunsint);
|
||||
#endif
|
||||
// Brugnoli was HERE
|
||||
pqa[1]=(unsigned SHORT)(((long int)nqt) >> BITSPERUI);
|
||||
pqa[0]=(unsigned SHORT)(((long int)nqt) & MAXUNSINT);
|
||||
|
||||
_MulUnsArrByUnsArr(ppd,pqa,ppt,10,2,ft);
|
||||
}
|
||||
while (_CompareUnsArr(copa,ppt,nc+1)==-1)
|
||||
{
|
||||
}
|
||||
|
||||
while (_CompareUnsArr(copa,ppt,nc+1)==-1)
|
||||
{
|
||||
_SubUnsArr(pqa,af,2);
|
||||
_MulUnsArrByUnsArr(ppd,pqa,ppt,10,2,ft);
|
||||
}
|
||||
}
|
||||
c[i]=pqa[0];
|
||||
_SubUnsArr(copa,ppt,m);
|
||||
nc--;
|
||||
}
|
||||
}
|
||||
|
||||
/* qui copa Š = al resto della divisione!! */
|
||||
|
||||
if (rf)
|
||||
{
|
||||
{
|
||||
_SubUnsArr(copb,af,n);
|
||||
_HalveUnsArr(copb,n);
|
||||
if (_CompareUnsArr(copa,copb,m)==1)
|
||||
{
|
||||
_IncrementUnsArr(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -27,24 +27,23 @@
|
||||
#include "gm.h"
|
||||
#include "gmsystem.h"
|
||||
|
||||
extern double pow(double, double);
|
||||
|
||||
|
||||
void _DivUnsArrByPwrOf10(a,n,p)
|
||||
unsigned SHORT a[];
|
||||
int n,p;
|
||||
{
|
||||
int ppdf;
|
||||
while (p>4)
|
||||
{
|
||||
{
|
||||
_DivUnsArrByUns(a,10000,n);
|
||||
p-=4;
|
||||
}
|
||||
#ifdef SH_LIB
|
||||
ppdf=1;
|
||||
for (i=1;i<=p;i++) ppdf*=10;
|
||||
#else
|
||||
ppdf=(int)pow(10.,(double)p);
|
||||
#endif
|
||||
_DivUnsArrByUnsRound(a,ppdf,n);
|
||||
}
|
||||
|
||||
switch (p)
|
||||
{
|
||||
case 0: _DivUnsArrByUnsRound(a,1,n); break;
|
||||
case 1: _DivUnsArrByUnsRound(a,10,n); break;
|
||||
case 2: _DivUnsArrByUnsRound(a,100,n); break;
|
||||
case 3: _DivUnsArrByUnsRound(a,1000,n); break;
|
||||
case 4: _DivUnsArrByUnsRound(a,10000,n); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
@ -27,27 +27,23 @@
|
||||
#include "gm.h"
|
||||
#include "gmsystem.h"
|
||||
|
||||
extern double pow(double, double);
|
||||
|
||||
|
||||
void _DivUnsArrByPwrOf10Trunc(a,n,p)
|
||||
unsigned SHORT a[];
|
||||
int n,p;
|
||||
{
|
||||
int ppdf;
|
||||
|
||||
while (p>4)
|
||||
{
|
||||
{
|
||||
_DivUnsArrByUns(a,10000,n);
|
||||
p-=4;
|
||||
}
|
||||
|
||||
#ifdef SH_LIB
|
||||
ppdf=1;
|
||||
for (i=1;i<=p;i++) ppdf*=10;
|
||||
#else
|
||||
ppdf=(int)pow(10.,(double)p);
|
||||
#endif
|
||||
_DivUnsArrByUns(a,ppdf,n);
|
||||
}
|
||||
|
||||
switch (p)
|
||||
{
|
||||
case 0: _DivUnsArrByUns(a,1,n); break;
|
||||
case 1: _DivUnsArrByUns(a,10,n); break;
|
||||
case 2: _DivUnsArrByUns(a,100,n); break;
|
||||
case 3: _DivUnsArrByUns(a,1000,n); break;
|
||||
case 4: _DivUnsArrByUns(a,10000,n); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
@ -32,20 +32,19 @@ extern double pow(double, double);
|
||||
|
||||
void _DivUnsArrByPwrOf10Trunc(unsigned SHORT a[],int n,int p)
|
||||
{
|
||||
int ppdf;
|
||||
|
||||
while (p>4)
|
||||
{
|
||||
{
|
||||
_DivUnsArrByUns(a,10000,n);
|
||||
p-=4;
|
||||
}
|
||||
|
||||
#ifdef SH_LIB
|
||||
ppdf=1;
|
||||
for (i=1;i<=p;i++) ppdf*=10;
|
||||
#else
|
||||
ppdf=(int)pow(10.,(double)p);
|
||||
#endif
|
||||
_DivUnsArrByUns(a,ppdf,n);
|
||||
}
|
||||
|
||||
case (p)
|
||||
{
|
||||
case 0: _DivUnsArrByUns(a,1,n); break;
|
||||
case 1: _DivUnsArrByUns(a,10,n); break;
|
||||
case 2: _DivUnsArrByUns(a,100,n); break;
|
||||
case 3: _DivUnsArrByUns(a,1000,n); break;
|
||||
case 4: _DivUnsArrByUns(a,10000,n); break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
43
gfm/dmi.c
43
gfm/dmi.c
@ -26,47 +26,32 @@
|
||||
#include "gm.h"
|
||||
#include "gmsystem.h"
|
||||
|
||||
extern double pow(double, double);
|
||||
|
||||
unsigned _DoubleUnsArr(a,n)
|
||||
unsigned SHORT a[];
|
||||
int n;
|
||||
{
|
||||
int i;
|
||||
unsigned long maxunsint,pdst;
|
||||
unsigned SHORT carry;
|
||||
unsigned long pdst;
|
||||
unsigned SHORT carry = 0;
|
||||
|
||||
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)
|
||||
{
|
||||
if (pdst>MAXUNSINT)
|
||||
{
|
||||
carry=(unsigned SHORT)(pdst>> BITSPERUI );
|
||||
a[i]=(unsigned SHORT)(pdst & maxunsint );
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((a[n-1]) >> (BITSPERUI-1))
|
||||
return(FAILURE);
|
||||
}
|
||||
return(GM_SUCCESS);
|
||||
}
|
||||
|
@ -1,2 +1,4 @@
|
||||
#define BITSPERUI 16
|
||||
#define SHORT short
|
||||
|
||||
#define MAXUNSINT (unsigned long)((1L<<BITSPERUI)-1)
|
||||
|
@ -57,7 +57,12 @@ extern DEC decPoint01;
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define SHORT short
|
||||
//#ifdef M_I386
|
||||
//#define SHORT short
|
||||
//#else
|
||||
//#define SHORT int
|
||||
//#endif
|
||||
|
||||
|
||||
int _AddDec80Bit( DEC *, DEC *, DEC *);
|
||||
int GF_CDECL _AddUnsArrToUnsArr( unsigned SHORT [], unsigned SHORT [],
|
||||
|
45
gfm/mgmn.c
45
gfm/mgmn.c
@ -37,49 +37,36 @@ int n,m,tmp1;
|
||||
{
|
||||
int i,j;
|
||||
unsigned long apdst[10];
|
||||
unsigned long pdst,maxunsint;
|
||||
unsigned long pdst;
|
||||
|
||||
tmp1=0;
|
||||
#ifdef SH_LIB
|
||||
maxunsint=1;
|
||||
for (i=1;i<=BITSPERUI;i++) maxunsint*=2;
|
||||
maxunsint--;
|
||||
#else
|
||||
maxunsint=(unsigned long)pow(2.,(double)BITSPERUI)-1;
|
||||
#endif
|
||||
|
||||
for(i=0;i<10;i++)
|
||||
{
|
||||
apdst[i]=0;
|
||||
}
|
||||
|
||||
for(i=0;i<n;i++)
|
||||
{
|
||||
{
|
||||
for(j=0;j<m;j++)
|
||||
{
|
||||
{
|
||||
pdst=(unsigned long)src1[j]*(unsigned long)src2[i];
|
||||
if (pdst>maxunsint)
|
||||
{
|
||||
apdst[i+j+1]+=(unsigned long)(pdst>>BITSPERUI);
|
||||
apdst[i+j]+=(unsigned long)(pdst&maxunsint);
|
||||
}
|
||||
else
|
||||
{
|
||||
apdst[i+j]+=(unsigned long)pdst;
|
||||
}
|
||||
}
|
||||
}
|
||||
for(i=0;i<10;i++)
|
||||
{
|
||||
if (apdst[i]>maxunsint)
|
||||
if (pdst>MAXUNSINT)
|
||||
{
|
||||
apdst[i+1]+=(unsigned long)(apdst[i]>>BITSPERUI);
|
||||
apdst[i]=(unsigned long)(apdst[i]&maxunsint);
|
||||
apdst[i+j+1]+=(unsigned long)(pdst>>BITSPERUI);
|
||||
apdst[i+j]+=(unsigned long)(pdst&MAXUNSINT);
|
||||
}
|
||||
else
|
||||
apdst[i+j]+=(unsigned long)pdst;
|
||||
}
|
||||
}
|
||||
for(i=0;i<10;i++)
|
||||
{
|
||||
if (apdst[i]>MAXUNSINT)
|
||||
{
|
||||
dst[i]=(unsigned SHORT)apdst[i];
|
||||
apdst[i+1]+=(unsigned long)(apdst[i]>>BITSPERUI);
|
||||
apdst[i]=(unsigned long)(apdst[i]&MAXUNSINT);
|
||||
}
|
||||
}
|
||||
for(i=0;i<10;i++)
|
||||
dst[i]=(unsigned SHORT)apdst[i];
|
||||
}
|
||||
|
||||
|
31
gfm/mli.c
31
gfm/mli.c
@ -27,42 +27,29 @@
|
||||
#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;
|
||||
unsigned long pdst[10];
|
||||
unsigned SHORT 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)
|
||||
{
|
||||
if (pdst[i]>MAXUNSINT)
|
||||
{
|
||||
carry=(unsigned SHORT)(pdst[i]>>BITSPERUI);
|
||||
dst[i]=(unsigned SHORT)(pdst[i]&maxunsint);
|
||||
}
|
||||
dst[i]=(unsigned SHORT)(pdst[i]&MAXUNSINT);
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
carry=0;
|
||||
dst[i]=(unsigned SHORT)pdst[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
69
gfm/mul10.c
69
gfm/mul10.c
@ -26,44 +26,31 @@
|
||||
#include "gm.h"
|
||||
#include "gmsystem.h"
|
||||
|
||||
extern double pow(double, double);
|
||||
|
||||
int Multiply(sr,num,m)
|
||||
unsigned SHORT sr[],num;
|
||||
int m;
|
||||
{
|
||||
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;
|
||||
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)
|
||||
{
|
||||
if (pdst[i]>MAXUNSINT)
|
||||
{
|
||||
carry=(unsigned SHORT)(pdst[i]>>BITSPERUI);
|
||||
sr[i]=(unsigned SHORT)(pdst[i]&maxunsint);
|
||||
}
|
||||
sr[i]=(unsigned SHORT)(pdst[i]&MAXUNSINT);
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
carry=0;
|
||||
sr[i]=(unsigned SHORT)pdst[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
return( (carry)? GM_OVERFLOW : GM_SUCCESS );
|
||||
}
|
||||
|
||||
@ -72,32 +59,28 @@ int _MulUnsArrByPwrOf10(pa,n,w)
|
||||
unsigned SHORT pa[];
|
||||
int n,w;
|
||||
{
|
||||
|
||||
int ppdf,k;
|
||||
|
||||
k=GM_SUCCESS;
|
||||
int k=GM_SUCCESS;
|
||||
|
||||
if (n>47)
|
||||
{
|
||||
k=GM_OVERFLOW;
|
||||
}
|
||||
return GM_OVERFLOW;
|
||||
|
||||
while ((n>4)&&(k==GM_SUCCESS))
|
||||
{
|
||||
k=Multiply(pa,10000,w);
|
||||
while (n>4)
|
||||
{
|
||||
k = Multiply(pa,10000,w);
|
||||
if (k != GM_SUCCESS)
|
||||
return k;
|
||||
n-=4;
|
||||
}
|
||||
}
|
||||
|
||||
if (k!=GM_OVERFLOW)
|
||||
{
|
||||
#ifdef SH_LIB
|
||||
ppdf=1;
|
||||
for (i=1;i<=n;i++) ppdf*=10;
|
||||
#else
|
||||
ppdf=(int)pow(10.,(double)n);
|
||||
#endif
|
||||
k=Multiply(pa,ppdf,w);
|
||||
}
|
||||
switch (n)
|
||||
{
|
||||
case 0: k=Multiply(pa,1,w); break;
|
||||
case 1: k=Multiply(pa,10,w); break;
|
||||
case 2: k=Multiply(pa,100,w); break;
|
||||
case 3: k=Multiply(pa,1000,w); break;
|
||||
case 4: k=Multiply(pa,10000,w); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
return(k);
|
||||
|
||||
|
103
gfm/mul10ad.c
103
gfm/mul10ad.c
@ -26,44 +26,32 @@
|
||||
#include "gm.h"
|
||||
#include "gmsystem.h"
|
||||
|
||||
extern double pow(double, double);
|
||||
|
||||
int Mltply(sr,num,m)
|
||||
unsigned SHORT sr[],num;
|
||||
int m;
|
||||
{
|
||||
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;
|
||||
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)
|
||||
{
|
||||
if (pdst[i]>MAXUNSINT)
|
||||
{
|
||||
carry=(unsigned SHORT)(pdst[i]>>BITSPERUI);
|
||||
sr[i]=(unsigned SHORT)(pdst[i]&maxunsint);
|
||||
}
|
||||
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 );
|
||||
}
|
||||
|
||||
@ -73,60 +61,39 @@ unsigned SHORT pa[];
|
||||
int c;
|
||||
{
|
||||
|
||||
int ppdf,k,i;
|
||||
unsigned long maxunsint,pdst,carry;
|
||||
unsigned SHORT dst[10];
|
||||
int ppdf = 10, i;
|
||||
unsigned long pdst, carry = c;
|
||||
unsigned SHORT dst[10];
|
||||
|
||||
k=GM_SUCCESS;
|
||||
#ifdef SH_LIB
|
||||
maxunsint=1;
|
||||
for (i=1;i<=BITSPERUI;i++) maxunsint*=2;
|
||||
maxunsint--;
|
||||
#else
|
||||
maxunsint=(unsigned long)pow(2.,(float)BITSPERUI)-1;
|
||||
#endif
|
||||
ppdf=10;
|
||||
for (i=0;i<=9;i++)
|
||||
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)
|
||||
{
|
||||
dst[i]=(i<5?pa[i]:0);
|
||||
carry=(pdst>>BITSPERUI);
|
||||
dst[i]=(unsigned SHORT)(pdst&MAXUNSINT);
|
||||
}
|
||||
k=Mltply(dst,ppdf,5);
|
||||
i=0;
|
||||
carry=c;
|
||||
|
||||
if (k!=GM_OVERFLOW)
|
||||
else
|
||||
{
|
||||
do
|
||||
{
|
||||
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;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
while (carry);
|
||||
dst[i]=(unsigned SHORT)pdst;
|
||||
carry=0;
|
||||
}
|
||||
}
|
||||
|
||||
if (i>5)
|
||||
{
|
||||
k=GM_OVERFLOW;
|
||||
}
|
||||
if (i>5) // va bene o dovrebbe essere 4
|
||||
return GM_OVERFLOW;
|
||||
|
||||
if (!k)
|
||||
{
|
||||
for (i=0;i<5;i++)
|
||||
{
|
||||
pa[i]=dst[i];
|
||||
}
|
||||
}
|
||||
for (i=0;i<5;i++)
|
||||
pa[i]=dst[i];
|
||||
|
||||
return(k);
|
||||
return(GM_SUCCESS);
|
||||
|
||||
}
|
||||
|
@ -42,9 +42,6 @@
|
||||
#include <malloc.h>
|
||||
#include "gm.h"
|
||||
#include "gmsystem.h"
|
||||
#ifdef SH_LIB
|
||||
#include "import.h"
|
||||
#endif
|
||||
|
||||
int _ScanfAux(int wOpt,char * sBuffer, char * sFmt, ELLIPSES)
|
||||
{
|
||||
|
51
gfm/sgmn.c
51
gfm/sgmn.c
@ -26,52 +26,27 @@
|
||||
#include "gm.h"
|
||||
#include "gmsystem.h"
|
||||
|
||||
extern double pow(double, double);
|
||||
|
||||
int _SubUnsArrFromUnsArr(src1, src2, dst, n)
|
||||
unsigned SHORT src1[], src2[], dst[];
|
||||
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
|
||||
unsigned long psrc;
|
||||
unsigned SHORT carry = 0;
|
||||
|
||||
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;
|
||||
}
|
||||
dst[i]=(unsigned SHORT)(psrc-(unsigned long)src2[i]);
|
||||
}
|
||||
if (carry)
|
||||
{
|
||||
return(GM_FAILURE);
|
||||
}
|
||||
else
|
||||
{
|
||||
return(GM_SUCCESS);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return(GM_SUCCESS);
|
||||
psrc= (long)src1[i] - (long)carry;
|
||||
carry = src2[i] > src1[i] ? 1 : 0;
|
||||
|
||||
if (carry)
|
||||
psrc += MAXUNSINT+0x1L;
|
||||
dst[i]=(unsigned SHORT)(psrc-(unsigned long)src2[i]);
|
||||
}
|
||||
if (carry)
|
||||
return(GM_FAILURE);
|
||||
}
|
||||
return(GM_SUCCESS);
|
||||
}
|
||||
|
37
gfm/smi.c
37
gfm/smi.c
@ -27,40 +27,23 @@
|
||||
#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;
|
||||
unsigned long psrc;
|
||||
unsigned SHORT carry = 0;
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
{
|
||||
psrc=(long)src1[i]-(long)carry;
|
||||
carry = src2[i]>src1[i] ? 1 : 0;
|
||||
if (carry)
|
||||
psrc += MAXUNSINT+0x1L;
|
||||
src1[i]=(unsigned SHORT)(psrc-(unsigned long)src2[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user