00001 // QMcBeaver 00002 // 00003 // Constructed by 00004 // 00005 // Michael Todd Feldmann 00006 // and 00007 // David Randall "Chip" Kent IV 00008 // 00009 // Copyright 2004. All rights reserved. 00010 // 00011 // drkent@users.sourceforge.net mtfeldmann@users.sourceforge.net 00012 00013 /************************************************************************** 00014 This SOFTWARE has been authored or contributed to by an employee or 00015 employees of the University of California, operator of the Los Alamos 00016 National Laboratory under Contract No. W-7405-ENG-36 with the U.S. 00017 Department of Energy. The U.S. Government has rights to use, reproduce, 00018 and distribute this SOFTWARE. Neither the Government nor the University 00019 makes any warranty, express or implied, or assumes any liability or 00020 responsibility for the use of this SOFTWARE. If SOFTWARE is modified 00021 to produce derivative works, such modified SOFTWARE should be clearly 00022 marked, so as not to confuse it with the version available from LANL. 00023 00024 Additionally, this program is free software; you can distribute it and/or 00025 modify it under the terms of the GNU General Public License. Accordingly, 00026 this program is distributed in the hope that it will be useful, but WITHOUT 00027 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00028 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00029 for more details. 00030 **************************************************************************/ 00031 00032 #include "IeeeMath.h" 00033 00034 template <class T> 00035 bool IeeeMath::isNaN(T x) 00036 { 00037 /* 00038 There is a decent probability that x is zero, 00039 so just in case the isfinite functions are "expensive", 00040 we'll take a shortcut here. 00041 */ 00042 //if(x == (T)(0)) return false; 00043 00052 #ifdef _WIN32 00053 if( x != x || !_finite(x) ) 00054 { 00055 return true; 00056 } 00057 else 00058 { 00059 return false; 00060 } 00061 #else 00062 00063 #ifdef USING_QSC 00064 //Apparently Tru64 doesn't have a "isfinite" function. 00065 if( x != x ) 00066 { 00067 return true; 00068 } 00069 else 00070 { 00071 return false; 00072 } 00073 #else 00074 if( x != x || !isfinite(x) ) 00075 { 00076 return true; 00077 } 00078 else 00079 { 00080 return false; 00081 } 00082 #endif 00083 00084 #endif 00085 } 00086 00087 //QSC compiler quits if this line is uncommented... 00088 #if ! defined USING_QSC 00089 template bool IeeeMath::isNaN<double>(double x); 00090 #endif 00091