title: Rules-of-thumb for minimising floating-point errors in C?
body: <p>Regarding minimising the error in floating-point operations, if I have an operation such as the following in C:</p>
  
  <pre><code>float a = 123.456;
  float b = 456.789;
  float r = 0.12345;
  a = a - (r * b);
  </code></pre>
  
  <p>Will the result of the calculation change if I split the multiplication and subtraction steps out, i.e.:</p>
  
  <pre><code>float c = r * b;
  a = a - c;
  </code></pre>
  
  <p>I am wondering whether a CPU would then treat these calculations differently and thereby the error may be smaller in one case?</p>
  
  <p>If not, which I presume anyway, are there any good rules-of-thumb to mitigate against floating-point error? Can I massage data in a way that will help?</p>
  
  <p>Please don't just say "use higher precision" - that's not what I'm after.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>For information about the data, in the general sense errors seem to be worse when the operation results in a very large number like 123456789. Small numbers, such as 1.23456789, seem to yield more accurate results after operations. Am I imagining this, or would scaling larger numbers help accuracy?</p>