appending arbitrary number of bits of a 4 byte number and extracting arbitrary number of bits from bitstream