/*****************************************************************************/ /* */ /* SUBROUTINE #2 (divides a 64-bit operand by 3, sets a flag if exact) */ /* 03/06/09 (dkc) */ /* */ /*****************************************************************************/ #include <math.h> void div64_32(unsigned int *a, unsigned int *b, unsigned int); void sub64(unsigned int *a, unsigned int *b); void add64(unsigned int *a, unsigned int *b); unsigned int subr2(unsigned int A, unsigned int B, unsigned int *P) { unsigned int flag; unsigned int K[2],T[2],U[2]; K[0]=A; K[1]=B; div64_32(K, T, 3); // k/3 U[0]=T[0]; U[1]=T[1]; P[0]=T[0]; P[1]=T[1]; add64(T, U); add64(T, U); // (k/3)*3 sub64(K, U); // k-(k/3)*3 flag=0; if ((U[0]==0)&&(U[1]==0)) flag=1; return(flag); }