Original Post
So I'm implementing a new bit stream (bit packing) class similar to what Jonathan Blow presented in his old gd mag articles and I've run into a performance concern when "un-packing" a value from the stream. Specifically there's a very intensive loop that for every bit in a value does a divide then modulus to get the byte and bit indices. Now for a 32-bit integer this is happening 32 times and for many iterations (this is for network data transmission code). I remember reading back a while ago that there is a way to do a modulus operation without having to actually call the operator but taking into account a few bit tricks when using integers. Can anyone point me to this information or explain how this might work. Your help is greatly appreciated and I thank you ahead of time.