title: Why does GCC yield -nan and clang and intel yield +nan for 0.0/0.0?
body: <p>When I was debugging code, I found that GCC and Clang both yield nan for <code>0.0/0.0</code> which is what I was expecting, but GCC yields an nan with the sign bit set to 1, while Clang sets it to 0 (in agreement with ICC, if I remember correctly).</p>
  
  <p>Now apparently both forms are allowed, but I keep wondering why <code>0.0/0.0</code> would make GCC output a "negative" result (printing it gives <code>-nan</code>), and <code>-(0.0/0.0)</code> gives a "positive" result? What is even more confusing is that <code>-0.0/0.0</code> is "negative" again. Is this a constant folding weirdness?</p>
  
  <p><strong>edit</strong></p>
  
  <p>Actually, it's the constant folding that makes it a positive nan. If I force the computation at runtime, I get negative nan on both GCC and Clang</p>
  
  <pre><code>volatile float zero = 0.0;
  std::cout &lt;&lt; (zero/zero); // -nan
  </code></pre>
  
  <p>Can someone sched some light on this please? Is the sign bit set to 1 on the x86 FPU?</p>