14 #ifndef __INCLUDED_SCOPIRA_TOOL_LIMITS_H__ 15 #define __INCLUDED_SCOPIRA_TOOL_LIMITS_H__ 17 #if defined(__GNUC__) && (__GNUC__ < 3) 26 #if defined(__sparc) || defined(__sparc__) || defined(__powerpc__) || defined(__ppc__) || defined(__hppa) || defined(_MIPSEB) 27 #define BOOST_BIG_ENDIAN 28 #elif defined(__i386__) 29 #define BOOST_LITTLE_ENDIAN 31 #error The file boost/detail/limits.hpp needs to be set up for your CPU type. 36 enum float_round_style {
37 round_indeterminate = -1,
38 round_toward_zero = 0,
40 round_toward_infinity = 2,
41 round_toward_neg_infinity = 3
44 enum float_denorm_style {
45 denorm_indeterminate = -1,
63 #ifdef BOOST_NO_INCLASS_MEMBER_INITIALIZATION 64 # define BOOST_STL_DECLARE_LIMITS_MEMBER(__mem_type, __mem_name, __mem_value) \ 65 enum { __mem_name = __mem_value } 67 # define BOOST_STL_DECLARE_LIMITS_MEMBER(__mem_type, __mem_name, __mem_value) \ 68 static const __mem_type __mem_name = __mem_value 73 template <
class __number>
74 class _Numeric_limits_base {
76 BOOST_STL_DECLARE_LIMITS_MEMBER(
bool, is_specialized,
false);
78 static __number
min() throw() {
return __number(); }
79 static __number
max() throw() {
return __number(); }
81 BOOST_STL_DECLARE_LIMITS_MEMBER(
int, digits, 0);
82 BOOST_STL_DECLARE_LIMITS_MEMBER(
int, digits10, 0);
84 BOOST_STL_DECLARE_LIMITS_MEMBER(
bool, is_signed,
false);
85 BOOST_STL_DECLARE_LIMITS_MEMBER(
bool, is_integer,
false);
86 BOOST_STL_DECLARE_LIMITS_MEMBER(
bool, is_exact,
false);
88 BOOST_STL_DECLARE_LIMITS_MEMBER(
int, radix, 0);
90 static __number epsilon() throw() {
return __number(); }
91 static __number round_error() throw() {
return __number(); }
93 BOOST_STL_DECLARE_LIMITS_MEMBER(
int, min_exponent, 0);
94 BOOST_STL_DECLARE_LIMITS_MEMBER(
int, min_exponent10, 0);
95 BOOST_STL_DECLARE_LIMITS_MEMBER(
int, max_exponent, 0);
96 BOOST_STL_DECLARE_LIMITS_MEMBER(
int, max_exponent10, 0);
98 BOOST_STL_DECLARE_LIMITS_MEMBER(
bool, has_infinity,
false);
99 BOOST_STL_DECLARE_LIMITS_MEMBER(
bool, has_quiet_NaN,
false);
100 BOOST_STL_DECLARE_LIMITS_MEMBER(
bool, has_signaling_NaN,
false);
101 BOOST_STL_DECLARE_LIMITS_MEMBER(float_denorm_style,
104 BOOST_STL_DECLARE_LIMITS_MEMBER(
bool, has_denorm_loss,
false);
106 static __number infinity() throw() {
return __number(); }
107 static __number quiet_NaN() throw() {
return __number(); }
108 static __number signaling_NaN() throw() {
return __number(); }
109 static __number denorm_min() throw() {
return __number(); }
111 BOOST_STL_DECLARE_LIMITS_MEMBER(
bool, is_iec559,
false);
112 BOOST_STL_DECLARE_LIMITS_MEMBER(
bool, is_bounded,
false);
113 BOOST_STL_DECLARE_LIMITS_MEMBER(
bool, is_modulo,
false);
115 BOOST_STL_DECLARE_LIMITS_MEMBER(
bool, traps,
false);
116 BOOST_STL_DECLARE_LIMITS_MEMBER(
bool, tinyness_before,
false);
117 BOOST_STL_DECLARE_LIMITS_MEMBER(float_round_style,
124 template <
class _Int,
128 class _Integer_limits :
public _Numeric_limits_base<_Int>
131 BOOST_STL_DECLARE_LIMITS_MEMBER(
bool, is_specialized,
true);
133 static _Int
min() throw() {
return __imin; }
134 static _Int
max() throw() {
return __imax; }
136 BOOST_STL_DECLARE_LIMITS_MEMBER(
int,
138 (__idigits < 0) ? (
int)(
sizeof(_Int) * CHAR_BIT)
139 - (__imin == 0 ? 0 : 1)
141 BOOST_STL_DECLARE_LIMITS_MEMBER(
int, digits10, (digits * 301) / 1000);
144 BOOST_STL_DECLARE_LIMITS_MEMBER(
bool, is_signed, __imin != 0);
145 BOOST_STL_DECLARE_LIMITS_MEMBER(
bool, is_integer,
true);
146 BOOST_STL_DECLARE_LIMITS_MEMBER(
bool, is_exact,
true);
147 BOOST_STL_DECLARE_LIMITS_MEMBER(
int, radix, 2);
149 BOOST_STL_DECLARE_LIMITS_MEMBER(
bool, is_bounded,
true);
150 BOOST_STL_DECLARE_LIMITS_MEMBER(
bool, is_modulo,
true);
153 #if defined(BOOST_BIG_ENDIAN) 155 template<
class Number,
unsigned int Word>
157 static Number get_word() throw() {
159 const unsigned int _S_word[4] = { Word, 0, 0, 0 };
160 return *
reinterpret_cast<const Number*
>(&_S_word);
166 template<
class Number,
unsigned int Word>
168 static Number get_word() throw() {
170 const unsigned int _S_word[4] = { 0, 0, 0, Word };
171 return *
reinterpret_cast<const Number*
>(
172 reinterpret_cast<const char *
>(&_S_word)+16-
173 (
sizeof(Number) == 12 ? 10 :
sizeof(Number)));
180 template <
class __number,
181 int __Digits,
int __Digits10,
182 int __MinExp,
int __MaxExp,
183 int __MinExp10,
int __MaxExp10,
184 unsigned int __InfinityWord,
185 unsigned int __QNaNWord,
unsigned int __SNaNWord,
187 float_round_style __RoundStyle>
188 class _Floating_limits :
public _Numeric_limits_base<__number>
191 BOOST_STL_DECLARE_LIMITS_MEMBER(
bool, is_specialized,
true);
193 BOOST_STL_DECLARE_LIMITS_MEMBER(
int, digits, __Digits);
194 BOOST_STL_DECLARE_LIMITS_MEMBER(
int, digits10, __Digits10);
196 BOOST_STL_DECLARE_LIMITS_MEMBER(
bool, is_signed,
true);
198 BOOST_STL_DECLARE_LIMITS_MEMBER(
int, radix, 2);
200 BOOST_STL_DECLARE_LIMITS_MEMBER(
int, min_exponent, __MinExp);
201 BOOST_STL_DECLARE_LIMITS_MEMBER(
int, max_exponent, __MaxExp);
202 BOOST_STL_DECLARE_LIMITS_MEMBER(
int, min_exponent10, __MinExp10);
203 BOOST_STL_DECLARE_LIMITS_MEMBER(
int, max_exponent10, __MaxExp10);
205 BOOST_STL_DECLARE_LIMITS_MEMBER(
bool, has_infinity,
true);
206 BOOST_STL_DECLARE_LIMITS_MEMBER(
bool, has_quiet_NaN,
true);
207 BOOST_STL_DECLARE_LIMITS_MEMBER(
bool, has_signaling_NaN,
true);
208 BOOST_STL_DECLARE_LIMITS_MEMBER(float_denorm_style,
210 denorm_indeterminate);
211 BOOST_STL_DECLARE_LIMITS_MEMBER(
bool, has_denorm_loss,
false);
214 static __number infinity() throw() {
215 return float_helper<__number, __InfinityWord>::get_word();
217 static __number quiet_NaN() throw() {
218 return float_helper<__number,__QNaNWord>::get_word();
220 static __number signaling_NaN() throw() {
221 return float_helper<__number,__SNaNWord>::get_word();
224 BOOST_STL_DECLARE_LIMITS_MEMBER(
bool, is_iec559, __IsIEC559);
225 BOOST_STL_DECLARE_LIMITS_MEMBER(
bool, is_bounded,
true);
226 BOOST_STL_DECLARE_LIMITS_MEMBER(
bool, traps,
false );
227 BOOST_STL_DECLARE_LIMITS_MEMBER(
bool, tinyness_before,
false);
229 BOOST_STL_DECLARE_LIMITS_MEMBER(float_round_style, round_style, __RoundStyle);
237 class numeric_limits :
public _Numeric_limits_base<T> {};
242 class numeric_limits<bool>
243 :
public _Integer_limits<bool, false, true, 0>
247 class numeric_limits<char>
248 :
public _Integer_limits<char, CHAR_MIN, CHAR_MAX>
252 class numeric_limits<signed char>
253 :
public _Integer_limits<signed char, SCHAR_MIN, SCHAR_MAX>
257 class numeric_limits<unsigned char>
258 :
public _Integer_limits<unsigned char, 0, UCHAR_MAX>
261 #ifndef BOOST_NO_INTRINSIC_WCHAR_T 263 class numeric_limits<wchar_t>
264 #if !defined(WCHAR_MAX) || !defined(WCHAR_MIN)
265 #if defined(_WIN32) || defined(__CYGWIN__)
266 :
public _Integer_limits<wchar_t, 0, USHRT_MAX>
267 #elif defined(__hppa) 269 :
public _Integer_limits<wchar_t, 0, UINT_MAX>
272 :
public _Integer_limits<wchar_t, INT_MIN, INT_MAX>
276 :
public _Integer_limits<wchar_t, WCHAR_MIN, WCHAR_MAX>
282 class numeric_limits<short>
283 :
public _Integer_limits<short, SHRT_MIN, SHRT_MAX>
287 class numeric_limits<unsigned short>
288 :
public _Integer_limits<unsigned short, 0, USHRT_MAX>
292 class numeric_limits<int>
293 :
public _Integer_limits<int, INT_MIN, INT_MAX>
297 class numeric_limits<unsigned int>
298 :
public _Integer_limits<unsigned int, 0, UINT_MAX>
302 class numeric_limits<long>
303 :
public _Integer_limits<long, LONG_MIN, LONG_MAX>
307 class numeric_limits<unsigned long>
308 :
public _Integer_limits<unsigned long, 0, ULONG_MAX>
316 #if !defined(LONGLONG_MIN) && !defined(LONGLONG_MAX) \ 317 && !defined(ULONGLONG_MAX) 319 #define ULONGLONG_MAX 0xffffffffffffffffLLU 320 #define LONGLONG_MAX 0x7fffffffffffffffLL 321 #define LONGLONG_MIN (-LONGLONG_MAX - 1) 326 class numeric_limits<long long>
327 :
public _Integer_limits<long long, LONGLONG_MIN, LONGLONG_MAX>
331 class numeric_limits<unsigned long long>
332 :
public _Integer_limits<unsigned long long, 0, ULONGLONG_MAX>
339 template<>
class numeric_limits<float>
340 :
public _Floating_limits<float,
347 #if defined(BOOST_BIG_ENDIAN)
348 0x7f80 << (sizeof(int)*CHAR_BIT-16),
349 0x7f81 << (sizeof(int)*CHAR_BIT-16),
350 0x7fc1 << (sizeof(int)*CHAR_BIT-16),
360 static float min() throw() { return FLT_MIN; }
361 static float denorm_min() throw() { return FLT_MIN; }
362 static float max() throw() { return FLT_MAX; }
363 static float epsilon() throw() { return FLT_EPSILON; }
364 static float round_error() throw() { return 0.5f; }
367 template<> class numeric_limits<double>
368 : public _Floating_limits<double,
375 #if defined(BOOST_BIG_ENDIAN)
376 0x7ff0 << (sizeof(int)*CHAR_BIT-16),
377 0x7ff1 << (sizeof(int)*CHAR_BIT-16),
378 0x7ff9 << (sizeof(int)*CHAR_BIT-16),
388 static double min() throw() { return DBL_MIN; }
389 static double denorm_min() throw() { return DBL_MIN; }
390 static double max() throw() { return DBL_MAX; }
391 static double epsilon() throw() { return DBL_EPSILON; }
392 static double round_error() throw() { return 0.5; }
395 template<> class numeric_limits<long double>
396 : public _Floating_limits<long double,
403 #if defined(BOOST_BIG_ENDIAN)
404 0x7ff0 << (sizeof(int)*CHAR_BIT-16),
405 0x7ff1 << (sizeof(int)*CHAR_BIT-16),
406 0x7ff9 << (sizeof(int)*CHAR_BIT-16),
416 static long double min() throw() { return LDBL_MIN; }
417 static long double denorm_min() throw() { return LDBL_MIN; }
418 static long double max() throw() { return LDBL_MAX; }
419 static long double epsilon() throw() { return LDBL_EPSILON; }
420 static long double round_error() throw() { return 4; }
size_t min(const V &v, T &out)
Definition: vectormath.h:275
size_t max(const V &v, T &out)
Definition: vectormath.h:297