title: Where is the floating point problem in this C# financial calculation?
body: <p>I receive a FIX message for a trade Allocation, where Price is given in <em>cents</em> (ZAR / 100), but commission is given in <em>Rands</em>.  These values are represented by the constants.  When I run this calculation, <code>commPerc1</code> shows a value of 0.099999999999999978, and <code>commPerc2</code> shows 0.1.  These values look to differ by x10, yet with the check of calculating back to <em>Rands</em>, both <code>commRands1</code> and <code>commRands2</code> show very similar values of 336.4831554 and 336.48315540000004 respectively.</p>
  
  <pre><code>private const double Price = 5708.91;
  private const double Qty = 5894;
  private const double AbsComm = 336.4831554;
  
  static void Main()
  {
  
      double commCents = AbsComm * 100;
      double commPerc1 = commCents / (Qty * Price) * 100;
      double commRands1 = (Qty * Price) * (commPerc1 / 100) / 100;
  
      double commPerc2 = (AbsComm / (Qty * (Price / 100))) * 100;
      double commRands2 = (Qty * Price) * (commPerc2 / 100) / 100;
  }
  </code></pre>
  
  <p><strong>PLEASE NOTE:</strong>
  I am dealing with legacy code here where a conversion to decimal would involve several changes and QA, so right now I have to accept <code>double</code>.</p>