title: C# double subtraction
body: <p>I need to do some work with variables of the type double and in the calculations I've come across something I do not understand. I know floating point types are not exact but it has enough precision for what I need.</p>
  
  <p>First I multiply a value of <strong>200</strong> with a multiplier of <strong>1.1</strong> and get <strong>220.00000000000003</strong> which is expected and close enough to <strong>220</strong> and then I subtract that from the expected value (<strong>220</strong>). The result should be <strong>0</strong> or very close to <strong>0</strong>. Instead I get <strong>-2.8421709430404007E-14</strong> which I cannot explain.</p>
  
  <pre><code>using System;
  
  namespace Test
  {
      class Program
      {
          static void Main(string[] args)
          {
              double u = 200;
              double v = 1.1;
              double x = u * v;
              double y = 220;
              double z = y - x;
  
              Console.WriteLine(u + " * " + v + " = " + x);
  
              Console.WriteLine(y + " - " + x + " = " + z);
  
              Console.ReadLine();
          }
      }
  }
  </code></pre>
  
  <p>Any ideas?</p>