Posted to tcl by GPS at Sun Sep 16 10:12:58 GMT 2007view pretty
#include <stdio.h> #include <stdlib.h> #include <inttypes.h> int main () { uint64_t targetvalue = 0x00adbeeffeedfaceULL; uint8_t parts[7] = {0xad, 0xbe, 0xef, 0xfe, 0xed, 0xfa, 0xce}; uint8_t outparts[7]; uint64_t acc = 0; int i; acc += parts[6]; acc += 0x100 * parts[5]; acc += 0x10000 * parts[4]; acc += 0x1000000ULL * parts[3]; acc += 0x100000000ULL * parts[2]; acc += 0x10000000000ULL * parts[1]; acc += 0x1000000000000ULL * parts[0]; printf ("%llx\n", acc); outparts[0] = acc / 0x1000000000000ULL; outparts[1] = acc / 0x10000000000ULL; outparts[2] = acc / 0x100000000ULL; outparts[3] = acc / 0x1000000ULL; outparts[4] = acc / 0x10000ULL; outparts[5] = acc / 0x100ULL; outparts[6] = acc & 0xff; for (i = 0; i < 7; ++i) { printf ("outparts[%d] = %x\n", i, outparts[i]); } return EXIT_SUCCESS; }