title: how do I make a portable isnan/isinf function
body: <p>I've been using <code>isinf</code>, <code>isnan</code> functions on Linux platforms which worked perfectly.
  But this didn't work on OS-X, so I decided to use <code>std::isinf</code> <code>std::isnan</code> which works on both Linux and OS-X.</p>
  
  <p>But the Intel compiler doesn't recognize it, and I guess its a bug in the intel compiler according to <a href="http://software.intel.com/en-us/forums/showthread.php?t=64188" rel="noreferrer">http://software.intel.com/en-us/forums/showthread.php?t=64188</a></p>
  
  <p>So now I just want to avoid the hassle and define my own <code>isinf</code>, <code>isnan</code> implementation.</p>
  
  <p>Does anyone know how this could be done?</p>
  
  <p>edit:</p>
  
  <p>I ended up doing this in my source code for making <code>isinf</code>/<code>isnan</code> working</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cmath&gt;
  
  #ifdef __INTEL_COMPILER
  #include &lt;mathimf.h&gt;
  #endif
  
  int isnan_local(double x) { 
  #ifdef __INTEL_COMPILER
    return isnan(x);
  #else
    return std::isnan(x);
  #endif
  }
  
  int isinf_local(double x) { 
  #ifdef __INTEL_COMPILER
    return isinf(x);
  #else
    return std::isinf(x);
  #endif
  }
  
  
  int myChk(double a){
    std::cerr&lt;&lt;"val is: "&lt;&lt;a &lt;&lt;"\t";
    if(isnan_local(a))
      std::cerr&lt;&lt;"program says isnan";
    if(isinf_local(a))
      std::cerr&lt;&lt;"program says isinf";
    std::cerr&lt;&lt;"\n";
    return 0;
  }
  
  int main(){
    double a = 0;
    myChk(a);
    myChk(log(a));
    myChk(-log(a));
    myChk(0/log(a));
    myChk(log(a)/log(a));
  
    return 0;
  }
  </code></pre>