Advertisement
Guest User

Untitled

a guest
Oct 3rd, 2014
513
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. unsigned long long ADC(unsigned long long * a, unsigned long long * b, bool * carry)
  2. {
  3.     unsigned long long result;
  4.     unsigned char * pr = (unsigned char *) &result;
  5.     unsigned char * pa = (unsigned char *) a;
  6.     unsigned char * pb = (unsigned char *) b;
  7.     unsigned short temp = (carry) ? 1 : 0;
  8.     for (int i = 0; i < 8; i++)
  9.     {        
  10.         temp += *pa++;
  11.         temp += *pb++;
  12.         *pr++ = (unsigned char) temp;
  13.         temp >>= 8;
  14.     }
  15.    
  16.     *carry = (temp != 0);
  17.     return result;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement