Does casting and assignment really strip away any extra precision of floats?
<p>I am reading through the <a href="https://isocpp.org/wiki/faq/newbie#floating-point-arith2">new C++ FAQ</a> and I see that even if <code>x == y</code> for <code>double x, y;</code> then it is possible for:</p>

<pre><code>std::cos(x) == std::cos(y)
</code></pre>

<p>to evaluate to <code>false</code>. This is because the machine can have a processor which supports extended precision, such that one part of the <code>==</code> is a 64 bit number while the other one is an 80 bit number.</p>

<p>However, the next example seems to be incorrect:</p>

<pre><code>void foo(double x, double y)
{
  double cos_x = cos(x);
  double cos_y = cos(y);
  // the behavior might depend on what's in here
  if (cos_x != cos_y) {
    std::cout &lt;&lt; "Huh?!?\n";  // You might end up here when x == y!!
  }
}
</code></pre>

<p>As far as I <a href="http://en.cppreference.com/w/cpp/types/climits/FLT_EVAL_METHOD">read on en.cppreference.com here</a>:</p>

<blockquote>
  <p>Cast and assignment strip away any extraneous range and precision:
  this models the action of storing a value from an extended-precision
  FPU register into a standard-sized memory location.</p>
</blockquote>

<p>Hence, assigning:</p>

<pre><code>double cos_x = cos(x);
double cos_y = cos(y);
</code></pre>

<p>should trim away any extra precision and make the program perfectly predictable.</p>

<p>So, who is right? The C++ FAQ, or the en.cppreference.com?</p>