title: C#/XNA - Multiplication faster than Division?
body: <p>I saw a tweet recently that confused me (this was posted by an XNA coder, in the context of writing an XNA game):</p>
  
  <p><a href="http://twitter.com/UberGeekGames/status/37641871681519616" rel="noreferrer">Microoptimization tip of the day: when possible, use multiplication instead of division in high frequency areas. It's a few cycles faster.</a></p>
  
  <p>I was quite surprised, because I always thought compilers where pretty smart (for example, using bit-shifting), and recently read a <a href="http://blogs.msdn.com/b/shawnhar/archive/2007/03/19/a-story-about-premature-optimization.aspx" rel="noreferrer">post by Shawn Hargreaves saying much the same thing</a>. I wondered how much truth there was in this, since there are lots of calculations in my game.</p>
  
  <p>I inquired, hoping for a sample, however the original poster was unable to give one. He did, however, say this:</p>
  
  <p><a href="http://twitter.com/UberGeekGames/status/37950450409934848" rel="noreferrer">Not necessarily when it's something like "center = width / 2". And I've already determined "yes, it's worth it". :)</a></p>
  
  <p>So, I'm curious...</p>
  
  <p><strong>Can anyone give an example of some code where you can change a division to a multiplication and get a performance gain, where the C# compiler wasn't able to do the same thing itself.</strong></p>