+size_t nbytes(size_t nbits) {
+ return (nbits/8)+((nbits%8)>0);
+}
+
+uint32_t SwapBits(uint32_t value, int nrbits) {
+ int i;
+ uint32_t newvalue = 0;
+ for(i = 0; i < nrbits; i++) {
+ newvalue ^= ((value >> i) & 1) << (nrbits - 1 - i);
+ }
+ return newvalue;
+}
+