title: Is C# Decimal Rounding Inconsistent?
body: <p>I've been fighting decimal precision in C# coming from a SQL Decimal (38,30) and I've finally made it all the way to a rounding oddity.  I know I'm probably overlooking the obvious here, but I need a little insight.</p>
  
  <p>The problem I'm having is that C# doesn't produce what I would consider to be consistent output.</p>
  
  <pre><code>decimal a = 0.387518769125m;
  decimal b = 0.3875187691250002636113061835m;
  
  Console.WriteLine(Math.Round(a, 11));
  Console.WriteLine(Math.Round(b, 11));
  Console.WriteLine(Math.Round(a, 11) == Math.Round(b, 11));
  </code></pre>
  
  <p>Yields</p>
  
  <pre><code>0.38751876912
  0.38751876913
  False
  </code></pre>
  
  <p>Uhh, 0.38751876913? Really?  What am I missing here?</p>
  
  <p>From <a href="http://msdn.microsoft.com/en-us/library/ms131275.aspx" rel="noreferrer">MSDN</a>:</p>
  
  <blockquote>
    <p>If the digit in the decimals position is odd, it is changed to an even digit. Otherwise, it is left unchanged.</p>
  </blockquote>
  
  <p>Why am I seeing inconsistent results?  The additional precision isn't changing the 'digit in the decimals position'...</p>