title: Efficiently multiplying with a constant fraction in C++
body: <p>I am implementing a Runge–Kutta procedure, which includes several time-critical multiplications with fixed, complicated fractions (which are not magic numbers but inherent to the algorithm) and I want this multiplications to be performed as efficient as possible whilst keeping the code readable.</p>
  
  <p>For simplicity’s sake, let’s assume my code would look like the following, if I did not need to care about efficiency:</p>
  
  <pre><code>for (int i = 0; i &lt; n; i++)
      a[i] += f(i) + b[i] * (2197/4104.);
  </code></pre>
  
  <p>Can I assume that every reasonable compiler (with optimisation) will effectively replace 2197/4104 by 0.535331…? If not, what are good ways to ensure this? Would defining a <code>const double</code> suffice, for example?</p>
  
  <p>(Note that I am not interested in other possibilities for optimisation of the above code – it’s really just an example.)</p>