/home/coin/DyLP-1.3.0/1.3/CoinUtils/src/CoinFinite.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2002, International Business Machines
00002 // Corporation and others.  All Rights Reserved.
00003 
00004 // Also put all base defines here e.g. VC++ pragmas
00005 #ifndef CoinFinite_H
00006 #define CoinFinite_H
00007 
00008 #include "CoinUtilsConfig.h"
00009 
00010 #ifdef HAVE_CMATH
00011 # include <cmath>
00012 #else
00013 # ifdef HAVE_MATH_H
00014 #  include <math.h>
00015 # else
00016 #  error "don't have header file for math"
00017 # endif
00018 #endif
00019 
00020 #ifdef HAVE_CFLOAT
00021 # include <cfloat>
00022 #else
00023 # ifdef HAVE_FLOAT_H
00024 #  include <float.h>
00025 # endif
00026 #endif
00027 
00028 #ifdef HAVE_CIEEEFP
00029 # include <cieeefp>
00030 #else
00031 # ifdef HAVE_IEEEFP_H
00032 #  include <ieeefp.h>
00033 # endif
00034 #endif
00035 
00036 #include <algorithm>
00037 
00038 //=============================================================================
00039 #if COIN_BIG_INDEX==0
00040 typedef int CoinBigIndex;
00041 #elif COIN_BIG_INDEX==1
00042 typedef long CoinBigIndex;
00043 #else
00044 typedef long long CoinBigIndex;
00045 #endif
00046 
00047 //=============================================================================
00048 // Plus infinity (double and int)
00049 #ifndef COIN_DBL_MAX
00050 #define COIN_DBL_MAX DBL_MAX
00051 #endif
00052 
00053 #ifndef COIN_INT_MAX
00054 #define COIN_INT_MAX ((int)((~((unsigned int)0)) >> 1))
00055 #endif
00056 
00057 //=============================================================================
00058 
00059 #if defined(_MSC_VER)
00060 //  # define CoinIsnan   _isnan
00061 //  # define CoinFinite  _finite
00062 // Turn off compiler warning about long names
00063 #  pragma warning(disable:4786)
00064 #if !defined(min)
00065 #define min(a,b)  (((a) < (b)) ? (a) : (b))
00066 #endif
00067 #if !defined(max)
00068 #define max(a,b)  (((a) > (b)) ? (a) : (b))
00069 #endif
00070 #else
00071 // Put standard min and max here
00072 using std::min;
00073 using std::max;
00074 #endif
00075 
00076 //=============================================================================
00077 
00078 inline bool CoinFinite(double val)
00079 {
00080 #ifdef MY_C_FINITE
00081   //    return static_cast<bool>(MY_C_FINITE(val));
00082     return MY_C_FINITE(val)!=0;
00083 #else
00084     return val != DBL_MAX && val != -DBL_MAX;
00085 #endif
00086 }
00087 
00088 //=============================================================================
00089 
00090 inline bool CoinIsnan(double val)
00091 {
00092 #ifdef MY_C_ISNAN
00093   //    return static_cast<bool>(MY_C_ISNAN(val));
00094     return MY_C_ISNAN(val)!=0;
00095 #else
00096     return false;
00097 #endif
00098 }
00099 
00100 //=============================================================================
00101 
00102 #endif

Generated on Fri Oct 26 03:03:48 2007 by  doxygen 1.4.7