title: Will the scope of floating point variables affect their values?
body: <p>If we execute the following C# code on a console application, we will get a message as <code>The sums are Not equal</code>.</p>
  
  <p>If we execute it after uncommenting the line <code>System.Console.WriteLine()</code>, we will get a message as <code>The sums are equal</code>.</p>
  
  <pre><code>    static void Main(string[] args)
      {
          float f = Sum(0.1f, 0.2f);
          float g = Sum(0.1f, 0.2f);
  
          //System.Console.WriteLine("f = " + f + " and g = " + g);
  
          if (f == g)
          {
              System.Console.WriteLine("The sums are equal");
          }
          else
          {
              System.Console.WriteLine("The sums are Not equal");
          }
      }
  
      static float Sum(float a, float b)
      {
          System.Console.WriteLine(a + b);
          return a + b;
      }
  </code></pre>
  
  <p>What is the actual reason for this behavior?</p>