How much faster is multiplication than division?

added by BucketSoft
10/4/2011 8:52:11 AM

255 Views

This is one of those things I learned a long time ago when I used to write a lot of animations, games, etc -- multiplication is faster than division. But I can't remember ever testing this to see exactly how much of a performance gap there was. I figured division might be 2 or 3 times slower. In fact, the difference is much greater than that.


1 comments

dpeterson
10/4/2011 8:54:44 AM
I think many other compilers and interpreters suffer this same problem. Some more advanced VM's get closer to speed parity (division in LuaJIT supposedly only lags 5% behind multiplication).
I'm not an expert on the internals of Intel or AMD processors, and I'm not sure what's going on under the hood in the CLR, but generally division is handled as repeated subtraction. I think the repeated subtraction is what makes it more costly but I'm not sure as to the technical reasons why.