OpenWalnut
1.2.5
|
00001 //--------------------------------------------------------------------------- 00002 // 00003 // Project: OpenWalnut ( http://www.openwalnut.org ) 00004 // 00005 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS 00006 // For more information see http://www.openwalnut.org/copying 00007 // 00008 // This file is part of OpenWalnut. 00009 // 00010 // OpenWalnut is free software: you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as published by 00012 // the Free Software Foundation, either version 3 of the License, or 00013 // (at your option) any later version. 00014 // 00015 // OpenWalnut is distributed in the hope that it will be useful, 00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 // GNU Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public License 00021 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>. 00022 // 00023 //--------------------------------------------------------------------------- 00024 00025 #ifndef WLIMITS_H 00026 #define WLIMITS_H 00027 00028 #include <stdint.h> // since <cstdint> is part of c++0x upcoming standard 00029 00030 #include <cstddef> 00031 #include <limits> 00032 00033 #include <boost/math/special_functions/fpclassify.hpp> // isnan, isinf 00034 00035 /** 00036 * Project wide limits for different quantitities. 00037 */ 00038 namespace wlimits 00039 { 00040 static const double MAX_DOUBLE = std::numeric_limits< double >::max(); //!< Maximum double value 00041 00042 static const float MAX_FLOAT = std::numeric_limits< float >::max(); //!< Maximum float value 00043 00044 static const size_t MAX_SIZE_T = std::numeric_limits< size_t >::max(); //!< Maximum size value 00045 00046 static const int32_t MAX_INT32_T = std::numeric_limits< int32_t >::max(); //!< Maximum int32_t value 00047 00048 static const double MIN_DOUBLE = std::numeric_limits< double >::min(); //!< Positive minimum double value 00049 00050 /** 00051 * Smallest double such: 1.0 + DBL_EPS == 1.0 is still true. 00052 */ 00053 static const double DBL_EPS = std::numeric_limits< double >::epsilon(); 00054 00055 /** 00056 * Smallest float such: 1.0 + FLT_EPS == 1.0 is still true. 00057 */ 00058 static const float FLT_EPS = std::numeric_limits< float >::epsilon(); 00059 00060 /** 00061 * Determines if a number is considered as NaN (aka Not a Number) or not. 00062 * 00063 * \note The reason for using here a wrapper to cmath's isnan is that it is only included in C99 which is not part of any existing C++ standard yet. 00064 * 00065 * \param value The value to be checked 00066 * 00067 * \return True if the value is a NaN, false otherwise. 00068 */ 00069 template< typename T > bool isnan( T value ); 00070 00071 /** 00072 * Determines if a number is considered as infinity or not. 00073 * 00074 * \note The reason for using here a wrapper to cmath's isinf is that it is only included in C99 which is not part of any existing C++ standard yet. 00075 * 00076 * \param value The value to be checked 00077 * 00078 * \return True if the value is infinity, false otherwise. 00079 */ 00080 template< typename T > bool isinf( T value ); 00081 } 00082 00083 template< typename T > bool wlimits::isnan( T value ) 00084 { 00085 return boost::math::isnan( value ); 00086 } 00087 00088 template< typename T > bool wlimits::isinf( T value ) 00089 { 00090 return boost::math::isinf( value ); 00091 } 00092 00093 #endif // WLIMITS_H