title: decimal vs double again
body: <p>I support a financial .net application. There is a lot of advice to use the <em>decimal</em> datatype for financial stuff. </p>
  
  <p>Now I am stuck with this:</p>
  
  <pre><code>decimal price = 1.0m/12.0m;
  decimal quantity = 2637.18m;
  decimal result = price * quantity;  //results in 219.76499999999999999999999991
  </code></pre>
  
  <p>The problem is that the correct value to charge our customer is 219.77 (round function, MidpointRounding.AwayFromZero) and not 219.76.</p>
  
  <p>If I change everything to double, it seems to work:</p>
  
  <pre><code>double price = 1.0/12.0;
  double quantity = 2637.18;
  double result = price * quantity;  //results in 219.765
  </code></pre>
  
  <p>Shall I change everything to double? Will there be other problems with fractions?</p>
  
  <p>I think this question is different from <a href="https://stackoverflow.com/questions/618535/difference-between-decimal-float-and-double-in-net">Difference between decimal, float and double in .NET?</a> because it does not really explain to me why the result with a more precise datatype <em>decimal</em> is less accurate (in the sample above) than the result with the <em>double</em> datatype which uses fewer bytes. </p>