This is an old revision of the document!
Packing
'Packing' refers to the practice of representing information using only the minimum number of bits required, and arranging those bits contiguously in memory or in a data stream. In other words, it avoids wasting unused bits when encoding values.
In data representation and programming, packing is often used to combine multiple values into a compact layout. This may involve packing fields into tuples or aggregate types, especially when memory usage, cache efficiency, storage size, or binary serialisation performance matters.
Minimum required bits
Encoding information into binary digits, or bits, requires a coding scheme that specifies how to encode and decode said information.
To calculate the minimum number of bits required for encoding
b = ⌈log₂(C)⌉