Campbell Ritchie wrote:Any case where multipyling or dividing integers by 2ⁿ where n is any integer smaller than the number of bits in the data type.
Of course, the followup question is "if shifting can be done via multiplying or dividing, then in what cases should you use shifting and in what cases should you use multiplying and dividing?".
My response is that certain things make sense, while others don't in this regard. It doesn't make sense to use shifting when the algorithm is calling for multiplying and dividing -- even if you can argue that they are functionally equivalent. Just because one can replace the other doesn't mean that it should be done -- and quite frankly, it should *not* be done as it will confuse people. After all, what happens when the "multiply by four" is to be changed to "multiply by five" because a fifth component was added?
Anyway, to answer the original question, I needed lots of shifting with networking programs especially those that need to set or get particular bits of headers. I also needed to use shifting a lot with graphic programs.