title: C# double addition - strange behaviour
body: <pre><code>public static void Main()
  {
      Dictionary&lt;string, double&gt; values = new Dictionary&lt;string, double&gt;();
      values.Add("a", 0.002);
      values.Add("b", 0.003);
      values.Add("c", 0.012);
  
      // Summing iteratively.
      double v1 = 615.0;
      foreach (KeyValuePair&lt;string, double&gt; kp in values)
      {
          v1 += kp.Value;
      }
  
      Console.WriteLine(v1);
  
      // Summing using the Sum method.
      double v2 = 615.0;
      v2 += values.Values.Sum();
  
      Console.WriteLine(v2);
  
      Console.ReadLine();
  }
  </code></pre>
  
  <p>When I look at the value of v1 in the debugger it gives a value of 615.01699999999994 but for v2 it gives a value of 615.017. For some reason the Sum method yields an accurate result whereas summing them iteratively does not. (When I print the two values they are the same, but I presume this is due to some rounding that the WriteLine method does.)</p>
  
  <p>Anyone know what is going on here?</p>