title: How to trace a NaN in C++
body: <p>I am going to do some math calculations using C++ .  The input floating point number is a valid number, but after the calculations, the resulting value is NaN. I would like to trace the point where NaN value appears (possibly using GDB), instead of inserting a lot of <code>isNan()</code> into the code.  But I found that even code like this will not trigger an exception when a NaN value appears.</p>
  
  <pre><code>double dirty = 0.0;
  double nanvalue = 0.0/dirty;
  </code></pre>
  
  <p>Could anyone suggest a method for tracing the NaN or turning a NaN into an exception?</p>