Calculation of two double fields different between Access and C#
<p>So I'm in the process of converting an application that has been running in Access for years and now going to C#/web application.  It deals with some pretty exact math and I've run into a problem with calculation of two double values.  </p>

<p>So in Access I have the following code:</p>

<pre><code>If Abs(varPartDataLocal(i, 0) - dblX_Star) &lt; dblTemp Then
</code></pre>

<p>Where varPartDataLocal(i, 0) = 1.00000232 (stored as string in a database) and dblX_Star = 1.00000226 (calculated by two string values that are converted to double and divided by 2) and when I get the Abs of those two values in Access I get:</p>

<blockquote>
  <p>5.999999986E-08</p>
</blockquote>

<p>whereas when I do the same code in C#:</p>

<pre><code>if (Math.Abs(Convert.ToDouble(varPartDataLocal[i, 0]) - dblX_Star) &lt; dblTemp)
</code></pre>

<p>I end us with:</p>

<blockquote>
  <p>6.0000000079441E-08</p>
</blockquote>

<p>However, if I do this in C# (basically the same as above I'm just not converting it from string to double):</p>

<pre><code>Math.Abs(1.00000232d - 1.00000226d)
</code></pre>

<p>then I get</p>

<blockquote>
  <p>5.99999998573963E-08 (which is the same as when I do this in Access)</p>
</blockquote>

<p>So the question is why the difference?</p>
