Bit twiddling and bitwise serialization primitives