char *cvsinfo = "cvsinfo: $Header: /home/cvsuser/cvsroot/JSOC/proj/globalhs/apps/calversfunctions.c,v 1.3 2013/04/28 07:58:43 tplarson Exp $"; /* the following function is taken directly from chapter 2 of Kernighan and Ritchie getbits: get n bits from position p */ unsigned long long getbits(unsigned long long x, int p, int n) { return (x >> (p+1-n)) & ~(~0ull << n); } /* Richard Heathfield's solution to exercise 2-6 of K&R */ unsigned long long setbits(unsigned long long x, int p, int n, unsigned long long y) { return (x & ((~0ull << (p + 1)) | (~(~0ull << (p + 1 - n))))) | ((y & ~(~0ull << n)) << (p + 1 - n)); // another solution (untested): //return (x & ~(~(~0<