title: Numerical Stability - does Multiply/Divide give a more precise value than Divide/Multiply?
body: <p>Consider the following code:</p>
  
  <pre class="lang-php prettyprint-override"><code>$result *= $oldFactor / $newFactor;  //using shorthand *= operator
  </code></pre>
  
  <p>which is actually this:</p>
  
  <pre class="lang-php prettyprint-override"><code>$result = $oldFactor / $newFactor * $result;  //division done first
  </code></pre>
  
  <p>I can also manually write it as this: </p>
  
  <pre class="lang-php prettyprint-override"><code>$result = $result * $oldFactor / $newFactor;  //multiplication done first
  </code></pre>
  
  <p>I am under impression that multiplication is a simpler operation and it does not suffer as much from rounding errors, compared to divide operation.  </p>
  
  <p>Also, I have this feeling that for most day-to-day human numbers, multiply operation will produce a "larger number" before it is divided (assuming numbers being used are often greater than 1).  And larger numbers after being divided are more numerically stable. Example .. consider <code>5 * 7 / 2.3</code> where first operation (mult) is precise, as those numbers are represented exactly in binary.  Then division is done and it's as precise as we are going to get.   But consider <code>7 / 2.3 * 5</code>, where first operation is divide, and already we produce a number that cannot be represented exactly in binary, and the next operation (mult) exaggerates any imprecision via multiplication.</p>
  
  <p>My question is basically ... does this matter?  Do I indeed lose precision when using divide first, or am I perfectly safe to use whichever ordering of operations that looks best for me and I will be getting the same result?</p>