00001 00008 /***************************************************************************** 00009 ** Ifdefs 00010 *****************************************************************************/ 00011 00012 #ifndef ECL_TYPE_TRAITS_NUMERIC_LIMITS_HPP_ 00013 #define ECL_TYPE_TRAITS_NUMERIC_LIMITS_HPP_ 00014 00015 /***************************************************************************** 00016 ** Includes 00017 *****************************************************************************/ 00018 00019 #include <limits> 00020 #include <climits> 00021 #include <ecl/config/portable_types.hpp> 00022 00023 /***************************************************************************** 00024 ** Namespaces 00025 *****************************************************************************/ 00026 00027 namespace ecl { 00028 00029 /***************************************************************************** 00030 ** Parent Template 00031 *****************************************************************************/ 00054 template <typename T> 00055 class numeric_limits : public std::numeric_limits<T> { 00056 public: 00057 numeric_limits() {} 00058 private: 00059 }; 00060 00061 /***************************************************************************** 00062 ** Specialisations 00063 *****************************************************************************/ 00069 template <> 00070 class numeric_limits<char> : public std::numeric_limits<char> { 00071 public: 00072 static const char one = 1; 00073 static const uint16 bits = ECL_SIZE_OF_CHAR*8; 00074 static const uint16 bytes = ECL_SIZE_OF_CHAR; 00075 static const char minimum = CHAR_MIN; 00076 static const char maximum = CHAR_MAX; 00077 00078 typedef float Precision; 00079 static const Precision dummy_precision = 0; 00080 }; 00081 00087 template <> 00088 class numeric_limits<unsigned char> : public std::numeric_limits<unsigned char> { 00089 public: 00090 static const unsigned char one = 1U; 00091 static const uint16 bits = ECL_SIZE_OF_CHAR*8; 00092 static const uint16 bytes = ECL_SIZE_OF_CHAR; 00093 static const unsigned char minimum = 0U; 00094 static const unsigned char maximum = UCHAR_MAX; 00095 00096 typedef float Precision; 00097 static const Precision dummy_precision = 0; 00098 }; 00099 00105 template <> 00106 class numeric_limits<short> : public std::numeric_limits<short> { 00107 public: 00108 static const short one = 1; 00109 static const uint16 bits = ECL_SIZE_OF_SHORT*8; 00110 static const uint16 bytes = ECL_SIZE_OF_SHORT; 00111 static const short minimum = SHRT_MIN; 00112 static const short maximum = SHRT_MAX; 00113 00114 typedef float Precision; 00115 static const Precision dummy_precision = 0; 00116 }; 00117 00123 template <> 00124 class numeric_limits<unsigned short> : public std::numeric_limits<unsigned short> { 00125 public: 00126 static const unsigned short one = 1U; 00127 static const uint16 bits = ECL_SIZE_OF_SHORT*8; 00128 static const uint16 bytes = ECL_SIZE_OF_SHORT; 00129 static const unsigned short minimum = 0U; 00130 static const unsigned short maximum = USHRT_MAX; 00131 00132 typedef float Precision; 00133 static const Precision dummy_precision = 0; 00134 }; 00135 00141 template <> 00142 class numeric_limits<int> : public std::numeric_limits<int> { 00143 public: 00144 static const int one = 1; 00145 static const uint16 bits = ECL_SIZE_OF_INT*8; 00146 static const uint16 bytes = ECL_SIZE_OF_INT; 00147 static const int minimum = INT_MIN; 00148 static const int maximum = INT_MAX; 00149 00150 typedef float Precision; 00151 static const Precision dummy_precision = 0; 00152 }; 00153 00159 template <> 00160 class numeric_limits<unsigned int> : public std::numeric_limits<unsigned int> { 00161 public: 00162 static const unsigned int one = 1U; 00163 static const uint16 bits = ECL_SIZE_OF_INT*8; 00164 static const uint16 bytes = ECL_SIZE_OF_INT; 00165 static const unsigned int minimum = 0U; 00166 static const unsigned int maximum = UINT_MAX; 00167 00168 typedef float Precision; 00169 static const Precision dummy_precision = 0; 00170 }; 00171 00172 00178 template <> 00179 class numeric_limits<long> : public std::numeric_limits<long> { 00180 public: 00181 static const long one = 1L; 00182 static const uint16 bits = ECL_SIZE_OF_LONG*8; 00183 static const uint16 bytes = ECL_SIZE_OF_LONG; 00184 static const long minimum = LONG_MIN; 00185 static const long maximum = LONG_MAX; 00186 00187 typedef float Precision; 00188 static const Precision dummy_precision = 0; 00189 }; 00190 00196 template <> 00197 class numeric_limits<unsigned long> : public std::numeric_limits<unsigned long> { 00198 public: 00199 static const unsigned long one = 1UL; 00200 static const uint16 bits = ECL_SIZE_OF_LONG*8; 00201 static const uint16 bytes = ECL_SIZE_OF_LONG; 00202 static const unsigned long minimum = 0UL; 00203 static const unsigned long maximum = ULONG_MAX; 00204 00205 typedef float Precision; 00206 static const Precision dummy_precision = 0; 00207 }; 00208 00214 template <> 00215 class numeric_limits<long long> : public std::numeric_limits<long long> { 00216 public: 00217 static const long long one = 1LL; 00218 static const uint16 bits = ECL_SIZE_OF_LONG_LONG*8; 00219 static const uint16 bytes = ECL_SIZE_OF_LONG_LONG; 00220 static const long long minimum = LONG_LONG_MIN; 00221 static const long long maximum = LONG_LONG_MAX; 00222 00223 typedef float Precision; 00224 static const Precision dummy_precision = 0; 00225 }; 00226 00232 template <> 00233 class numeric_limits<unsigned long long> : public std::numeric_limits<unsigned long long> { 00234 public: 00235 static const unsigned long long one = 1ULL; 00236 static const uint16 bits = ECL_SIZE_OF_LONG_LONG*8; 00237 static const uint16 bytes = ECL_SIZE_OF_LONG_LONG; 00238 static const unsigned long long minimum = 0ULL; 00239 static const unsigned long long maximum = ULONG_LONG_MAX; 00240 00241 typedef float Precision; 00242 static const Precision dummy_precision = 0; 00243 }; 00244 00250 template <> 00251 class numeric_limits<float> : public std::numeric_limits<float> { 00252 public: 00253 static const uint16 bits = ECL_SIZE_OF_FLOAT*8; 00254 static const uint16 bytes = ECL_SIZE_OF_FLOAT; 00255 00256 typedef float Precision; 00257 static const float dummy_precision; 00259 static const float minimum; 00260 static const float maximum; 00261 }; 00262 00268 template <> 00269 class numeric_limits<double> : public std::numeric_limits<double> { 00270 public: 00271 static const uint16 bits = ECL_SIZE_OF_DOUBLE*8; 00272 static const uint16 bytes = ECL_SIZE_OF_DOUBLE; 00273 00274 typedef double Precision; 00275 static const double dummy_precision; 00277 static const double minimum; 00278 static const double maximum; 00279 }; 00280 00286 template <> 00287 class numeric_limits<long double> : public std::numeric_limits<long double> { 00288 public: 00289 static const uint16 bits = ECL_SIZE_OF_LONG_DOUBLE*8; 00290 static const uint16 bytes = ECL_SIZE_OF_LONG_DOUBLE; 00291 00292 typedef long double Precision; 00293 static const long double dummy_precision; 00295 static const long double minimum; 00296 static const long double maximum; 00297 }; 00298 00299 00300 } // namespace ecl 00301 00302 #endif /* ECL_TYPE_TRAITS_NUMERIC_LIMITS_HPP_ */