title: Floating-point comparison of constant assignment
body: <p>When comparing doubles for equality, we need to give a tolerance level, because floating-point computation might introduce errors. For example:</p>
  
  <pre><code>double x; 
  double y; 
  x = f();
  y = g();
  
  if (fabs(x-y)&lt;epsilon) {
     // they are equal!
  } else {
     // they are not!
  }
  </code></pre>
  
  <p>However, if I simply <em>assign</em> a constant value, without any computation, do I still need to check the epsilon? </p>
  
  <pre><code>double x = 1;
  double y = 1;
  
  if (x==y) {
     // they are equal!
  } else {
     // no they are not!
  }
  </code></pre>
  
  <p>Is <code>==</code> comparison good enough? Or I need to do <code>fabs(x-y)&lt;epsilon</code> again? Is it possible to introduce error in assigning? Am I too paranoid? </p>
  
  <p>How about casting (<code>double x = static_cast&lt;double&gt;(100)</code>)? Is that gonna introduce floating-point error as well? </p>
  
  <p>I am using C++ on Linux, but if it differs by language, I would like to understand that as well.</p>