Packing numbers efficiently
<p>I have <code>n</code> numbers in the range of <code>0..m-1</code>. <code>m</code> doen't have to be a power of 2.<br>
The most efficient way to pack them into a stream of bytes will require exactly <code>log2(m)*n</code> bits rounded up.<br>
I get the numbers as a <code>List&lt;int&gt;</code> and <code>m</code> as <code>int m</code>. How can I pack it into <code>List&lt;byte&gt;</code> not exceeding the size of <code>log2(m)*n/8</code>?<br>
After the packing is done how can get the numbers back having the <code>List&lt;byte&gt;</code> and <code>int n, m</code>?</p>
