/* int _MulUnsArrP10AndAddInt(pa,c) * * ARGUMENT * unsigned pa[]; * int c; # to add after mult by 10 * * DESCRIPTION * Multiplies the number (<=80bits) in the int array by decimal 10 * and adds 'c' to it. Used in the divide routines for adjusting, * * SIDE EFFECTS * The value of pa is unchanged on overflow. * * RETURNS * GM_SUCCES if no overflow, otherwise GM_OVERFLOW * * AUTHOR * Brugnoli Giugno 1992 * * MODIFICATIONS * */ #include #include #include "gm.h" #include "gmsystem.h" int Mltply(sr,num,m) unsigned SHORT sr[],num; int m; { int i; unsigned long pdst[10]; unsigned SHORT carry = 0; for (i=0;iMAXUNSINT) { carry=(unsigned SHORT)(pdst[i]>>BITSPERUI); 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 ); } int _MulUnsArrP10AndAddInt(pa,c) unsigned SHORT pa[]; int c; { int ppdf = 10, i; unsigned long pdst, carry = c; unsigned SHORT dst[10]; 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) { carry=(pdst>>BITSPERUI); dst[i]=(unsigned SHORT)(pdst&MAXUNSINT); } else { dst[i]=(unsigned SHORT)pdst; carry=0; } } if (i>5) // va bene o dovrebbe essere 4 return GM_OVERFLOW; for (i=0;i<5;i++) pa[i]=dst[i]; return(GM_SUCCESS); }