| 1 |
/* |
| 2 |
* Copyright (c) 1997 |
| 3 |
* Silicon Graphics Computer Systems, Inc. |
| 4 |
* |
| 5 |
* Copyright (c) 1999 |
| 6 |
* Boris Fomitchev |
| 7 |
* |
| 8 |
* This material is provided "as is", with absolutely no warranty expressed |
| 9 |
* or implied. Any use is at your own risk. |
| 10 |
* |
| 11 |
* Permission to use or copy this software for any purpose is hereby granted |
| 12 |
* without fee, provided the above notices are retained on all copies. |
| 13 |
* Permission to modify the code and to distribute modified code is granted, |
| 14 |
* provided the above notices are retained, and a notice that the code was |
| 15 |
* modified is included with the above copyright notice. |
| 16 |
* |
| 17 |
*/ |
| 18 |
|
| 19 |
#ifndef _STLP_LIMITS |
| 20 |
# define _STLP_LIMITS |
| 21 |
|
| 22 |
# include <climits> |
| 23 |
# include <cfloat> |
| 24 |
|
| 25 |
#ifndef _STLP_OUTERMOST_HEADER_ID |
| 26 |
# define _STLP_OUTERMOST_HEADER_ID 0x39 |
| 27 |
# include <stl/_prolog.h> |
| 28 |
#endif |
| 29 |
|
| 30 |
#if defined (_STLP_HAS_WCHAR_T) && !defined (_STLP_INTERNAL_CWCHAR) |
| 31 |
# include <stl/_cwchar.h> |
| 32 |
#endif |
| 33 |
|
| 34 |
_STLP_BEGIN_NAMESPACE |
| 35 |
|
| 36 |
enum float_round_style { |
| 37 |
round_indeterminate = -1, |
| 38 |
round_toward_zero = 0, |
| 39 |
round_to_nearest = 1, |
| 40 |
round_toward_infinity = 2, |
| 41 |
round_toward_neg_infinity = 3 |
| 42 |
}; |
| 43 |
|
| 44 |
enum float_denorm_style { |
| 45 |
denorm_indeterminate = -1, |
| 46 |
denorm_absent = 0, |
| 47 |
denorm_present = 1 |
| 48 |
}; |
| 49 |
|
| 50 |
_STLP_MOVE_TO_PRIV_NAMESPACE |
| 51 |
|
| 52 |
// Base class for all specializations of numeric_limits. |
| 53 |
template <class __number> |
| 54 |
class _Numeric_limits_base { |
| 55 |
public: |
| 56 |
|
| 57 |
static __number (_STLP_CALL min)() noexcept { return __number(); } |
| 58 |
static __number (_STLP_CALL max)() noexcept { return __number(); } |
| 59 |
|
| 60 |
_STLP_STATIC_CONSTANT(int, digits = 0); |
| 61 |
_STLP_STATIC_CONSTANT(int, digits10 = 0); |
| 62 |
_STLP_STATIC_CONSTANT(int, radix = 0); |
| 63 |
_STLP_STATIC_CONSTANT(int, min_exponent = 0); |
| 64 |
_STLP_STATIC_CONSTANT(int, min_exponent10 = 0); |
| 65 |
_STLP_STATIC_CONSTANT(int, max_exponent = 0); |
| 66 |
_STLP_STATIC_CONSTANT(int, max_exponent10 = 0); |
| 67 |
|
| 68 |
_STLP_STATIC_CONSTANT(float_denorm_style, has_denorm = denorm_absent); |
| 69 |
_STLP_STATIC_CONSTANT(float_round_style, round_style = round_toward_zero); |
| 70 |
|
| 71 |
_STLP_STATIC_CONSTANT(bool, is_specialized = false); |
| 72 |
_STLP_STATIC_CONSTANT(bool, is_signed = false); |
| 73 |
_STLP_STATIC_CONSTANT(bool, is_integer = false); |
| 74 |
_STLP_STATIC_CONSTANT(bool, is_exact = false); |
| 75 |
_STLP_STATIC_CONSTANT(bool, has_infinity = false); |
| 76 |
_STLP_STATIC_CONSTANT(bool, has_quiet_NaN = false); |
| 77 |
_STLP_STATIC_CONSTANT(bool, has_signaling_NaN = false); |
| 78 |
_STLP_STATIC_CONSTANT(bool, has_denorm_loss = false); |
| 79 |
_STLP_STATIC_CONSTANT(bool, is_iec559 = false); |
| 80 |
_STLP_STATIC_CONSTANT(bool, is_bounded = false); |
| 81 |
_STLP_STATIC_CONSTANT(bool, is_modulo = false); |
| 82 |
_STLP_STATIC_CONSTANT(bool, traps = false); |
| 83 |
_STLP_STATIC_CONSTANT(bool, tinyness_before = false); |
| 84 |
|
| 85 |
static __number _STLP_CALL epsilon() noexcept { return __number(); } |
| 86 |
static __number _STLP_CALL round_error() noexcept { return __number(); } |
| 87 |
|
| 88 |
static __number _STLP_CALL infinity() noexcept { return __number(); } |
| 89 |
static __number _STLP_CALL quiet_NaN() noexcept { return __number(); } |
| 90 |
static __number _STLP_CALL signaling_NaN() noexcept { return __number(); } |
| 91 |
static __number _STLP_CALL denorm_min() noexcept { return __number(); } |
| 92 |
}; |
| 93 |
|
| 94 |
// Base class for integers. |
| 95 |
|
| 96 |
#ifdef _STLP_LIMITED_DEFAULT_TEMPLATES |
| 97 |
# ifdef _STLP_LONG_LONG |
| 98 |
# define _STLP_LIMITS_MIN_TYPE _STLP_LONG_LONG |
| 99 |
# define _STLP_LIMITS_MAX_TYPE unsigned _STLP_LONG_LONG |
| 100 |
# else |
| 101 |
# define _STLP_LIMITS_MIN_TYPE long |
| 102 |
# define _STLP_LIMITS_MAX_TYPE unsigned long |
| 103 |
# endif |
| 104 |
#else |
| 105 |
# define _STLP_LIMITS_MIN_TYPE _Int |
| 106 |
# define _STLP_LIMITS_MAX_TYPE _Int |
| 107 |
#endif /* _STLP_LIMITED_DEFAULT_TEMPLATES */ |
| 108 |
|
| 109 |
template <class _Int, |
| 110 |
_STLP_LIMITS_MIN_TYPE __imin, |
| 111 |
_STLP_LIMITS_MAX_TYPE __imax, |
| 112 |
int __idigits, bool __ismod> |
| 113 |
class _Integer_limits : public _Numeric_limits_base<_Int> { |
| 114 |
public: |
| 115 |
|
| 116 |
static _Int (_STLP_CALL min) () noexcept { return (_Int)__imin; } |
| 117 |
static _Int (_STLP_CALL max) () noexcept { return (_Int)__imax; } |
| 118 |
|
| 119 |
_STLP_STATIC_CONSTANT(int, digits = (__idigits < 0) ? ((int)((sizeof(_Int) * (CHAR_BIT))) - ((__imin == 0) ? 0 : 1)) : (__idigits)); |
| 120 |
_STLP_STATIC_CONSTANT(int, digits10 = (digits * 301UL) / 1000); |
| 121 |
_STLP_STATIC_CONSTANT(int, radix = 2); |
| 122 |
_STLP_STATIC_CONSTANT(bool, is_specialized = true); |
| 123 |
_STLP_STATIC_CONSTANT(bool, is_signed = (__imin != 0)); |
| 124 |
_STLP_STATIC_CONSTANT(bool, is_integer = true); |
| 125 |
_STLP_STATIC_CONSTANT(bool, is_exact = true); |
| 126 |
_STLP_STATIC_CONSTANT(bool, is_bounded = true); |
| 127 |
_STLP_STATIC_CONSTANT(bool, is_modulo = __ismod); |
| 128 |
}; |
| 129 |
|
| 130 |
// Base class for floating-point numbers. |
| 131 |
template <class __number, |
| 132 |
int __Digits, int __Digits10, |
| 133 |
int __MinExp, int __MaxExp, |
| 134 |
int __MinExp10, int __MaxExp10, |
| 135 |
bool __IsIEC559, |
| 136 |
float_denorm_style __DenormStyle, |
| 137 |
float_round_style __RoundStyle> |
| 138 |
class _Floating_limits : public _Numeric_limits_base<__number> { |
| 139 |
public: |
| 140 |
|
| 141 |
_STLP_STATIC_CONSTANT(int, digits = __Digits); |
| 142 |
_STLP_STATIC_CONSTANT(int, digits10 = __Digits10); |
| 143 |
_STLP_STATIC_CONSTANT(int, radix = FLT_RADIX); |
| 144 |
_STLP_STATIC_CONSTANT(int, min_exponent = __MinExp); |
| 145 |
_STLP_STATIC_CONSTANT(int, max_exponent = __MaxExp); |
| 146 |
_STLP_STATIC_CONSTANT(int, min_exponent10 = __MinExp10); |
| 147 |
_STLP_STATIC_CONSTANT(int, max_exponent10 = __MaxExp10); |
| 148 |
|
| 149 |
_STLP_STATIC_CONSTANT(float_denorm_style, has_denorm = __DenormStyle); |
| 150 |
_STLP_STATIC_CONSTANT(float_round_style, round_style = __RoundStyle); |
| 151 |
|
| 152 |
_STLP_STATIC_CONSTANT(bool, is_specialized = true); |
| 153 |
_STLP_STATIC_CONSTANT(bool, is_signed = true); |
| 154 |
|
| 155 |
_STLP_STATIC_CONSTANT(bool, has_infinity = true); |
| 156 |
#if (!defined (_STLP_MSVC) || (_STLP_MSVC > 1300)) && \ |
| 157 |
(!defined (__BORLANDC__) || (__BORLANDC__ >= 0x590)) && \ |
| 158 |
(!defined (_CRAY) || defined (_CRAYIEEE)) |
| 159 |
_STLP_STATIC_CONSTANT(bool, has_quiet_NaN = true); |
| 160 |
_STLP_STATIC_CONSTANT(bool, has_signaling_NaN = true); |
| 161 |
#else |
| 162 |
_STLP_STATIC_CONSTANT(bool, has_quiet_NaN = false); |
| 163 |
_STLP_STATIC_CONSTANT(bool, has_signaling_NaN = false); |
| 164 |
#endif |
| 165 |
|
| 166 |
_STLP_STATIC_CONSTANT(bool, is_iec559 = __IsIEC559 && has_infinity && has_quiet_NaN && has_signaling_NaN && (has_denorm == denorm_present)); |
| 167 |
_STLP_STATIC_CONSTANT(bool, has_denorm_loss = false); |
| 168 |
_STLP_STATIC_CONSTANT(bool, is_bounded = true); |
| 169 |
_STLP_STATIC_CONSTANT(bool, traps = true); |
| 170 |
_STLP_STATIC_CONSTANT(bool, tinyness_before = false); |
| 171 |
}; |
| 172 |
|
| 173 |
_STLP_MOVE_TO_STD_NAMESPACE |
| 174 |
|
| 175 |
// Class numeric_limits |
| 176 |
|
| 177 |
// The unspecialized class. |
| 178 |
|
| 179 |
template<class _Tp> |
| 180 |
class numeric_limits : public _STLP_PRIV _Numeric_limits_base<_Tp> {}; |
| 181 |
|
| 182 |
// Specializations for all built-in integral types. |
| 183 |
|
| 184 |
#if !defined (_STLP_NO_BOOL) |
| 185 |
_STLP_TEMPLATE_NULL |
| 186 |
class numeric_limits<bool> |
| 187 |
: public _STLP_PRIV _Integer_limits<bool, false, true, 1, false> |
| 188 |
{}; |
| 189 |
#endif /* _STLP_NO_BOOL */ |
| 190 |
|
| 191 |
_STLP_TEMPLATE_NULL |
| 192 |
class numeric_limits<char> |
| 193 |
: public _STLP_PRIV _Integer_limits<char, CHAR_MIN, CHAR_MAX, -1, true> |
| 194 |
{}; |
| 195 |
|
| 196 |
#if !defined (_STLP_NO_SIGNED_BUILTINS) |
| 197 |
_STLP_TEMPLATE_NULL |
| 198 |
class numeric_limits<signed char> |
| 199 |
: public _STLP_PRIV _Integer_limits<signed char, SCHAR_MIN, SCHAR_MAX, -1, true> |
| 200 |
{}; |
| 201 |
#endif |
| 202 |
|
| 203 |
_STLP_TEMPLATE_NULL |
| 204 |
class numeric_limits<unsigned char> |
| 205 |
: public _STLP_PRIV _Integer_limits<unsigned char, 0, UCHAR_MAX, -1, true> |
| 206 |
{}; |
| 207 |
|
| 208 |
#if !(defined (_STLP_NO_WCHAR_T) || defined (_STLP_WCHAR_T_IS_USHORT)) |
| 209 |
|
| 210 |
_STLP_TEMPLATE_NULL |
| 211 |
class numeric_limits<wchar_t> |
| 212 |
: public _STLP_PRIV _Integer_limits<wchar_t, WCHAR_MIN, WCHAR_MAX, -1, true> |
| 213 |
{}; |
| 214 |
|
| 215 |
#endif |
| 216 |
|
| 217 |
_STLP_TEMPLATE_NULL |
| 218 |
class numeric_limits<short> |
| 219 |
: public _STLP_PRIV _Integer_limits<short, SHRT_MIN, SHRT_MAX, -1, true> |
| 220 |
{}; |
| 221 |
|
| 222 |
_STLP_TEMPLATE_NULL |
| 223 |
class numeric_limits<unsigned short> |
| 224 |
: public _STLP_PRIV _Integer_limits<unsigned short, 0, USHRT_MAX, -1, true> |
| 225 |
{}; |
| 226 |
|
| 227 |
#if defined (__xlC__) && (__xlC__ == 0x500) |
| 228 |
# undef INT_MIN |
| 229 |
# define INT_MIN -2147483648 |
| 230 |
#endif |
| 231 |
|
| 232 |
_STLP_TEMPLATE_NULL |
| 233 |
class numeric_limits<int> |
| 234 |
: public _STLP_PRIV _Integer_limits<int, INT_MIN, INT_MAX, -1, true> |
| 235 |
{}; |
| 236 |
|
| 237 |
_STLP_TEMPLATE_NULL |
| 238 |
class numeric_limits<unsigned int> |
| 239 |
: public _STLP_PRIV _Integer_limits<unsigned int, 0, UINT_MAX, -1, true> |
| 240 |
{}; |
| 241 |
|
| 242 |
_STLP_TEMPLATE_NULL |
| 243 |
class numeric_limits<long> |
| 244 |
: public _STLP_PRIV _Integer_limits<long, LONG_MIN, LONG_MAX, -1, true> |
| 245 |
{}; |
| 246 |
|
| 247 |
_STLP_TEMPLATE_NULL |
| 248 |
class numeric_limits<unsigned long> |
| 249 |
: public _STLP_PRIV _Integer_limits<unsigned long, 0, ULONG_MAX, -1, true> |
| 250 |
{}; |
| 251 |
|
| 252 |
#if defined (_STLP_LONG_LONG) |
| 253 |
|
| 254 |
# if defined (_STLP_MSVC) || defined (__BORLANDC__) |
| 255 |
# define LONGLONG_MAX 0x7fffffffffffffffi64 |
| 256 |
# define LONGLONG_MIN (-LONGLONG_MAX-1i64) |
| 257 |
# define ULONGLONG_MAX 0xffffffffffffffffUi64 |
| 258 |
# else |
| 259 |
# ifndef LONGLONG_MAX |
| 260 |
# define LONGLONG_MAX 0x7fffffffffffffffLL |
| 261 |
# endif |
| 262 |
# ifndef LONGLONG_MIN |
| 263 |
# define LONGLONG_MIN (-LONGLONG_MAX-1LL) |
| 264 |
# endif |
| 265 |
# ifndef ULONGLONG_MAX |
| 266 |
# define ULONGLONG_MAX 0xffffffffffffffffULL |
| 267 |
# endif |
| 268 |
# endif |
| 269 |
|
| 270 |
# if !defined (__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ <= 96) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 3) |
| 271 |
|
| 272 |
_STLP_TEMPLATE_NULL |
| 273 |
class numeric_limits<_STLP_LONG_LONG> |
| 274 |
: public _STLP_PRIV _Integer_limits<_STLP_LONG_LONG, LONGLONG_MIN, LONGLONG_MAX, -1, true> |
| 275 |
{}; |
| 276 |
|
| 277 |
_STLP_TEMPLATE_NULL |
| 278 |
class numeric_limits<unsigned _STLP_LONG_LONG> |
| 279 |
: public _STLP_PRIV _Integer_limits<unsigned _STLP_LONG_LONG, 0, ULONGLONG_MAX, -1, true> |
| 280 |
{}; |
| 281 |
# else /* gcc 2.97 (after 2000-11-01), 2.98, 3.0 */ |
| 282 |
/* |
| 283 |
newest gcc has new mangling scheme, that has problem |
| 284 |
with generating name [instantiated] of template specialization like |
| 285 |
_Integer_limits<_STLP_LONG_LONG, LONGLONG_MIN, LONGLONG_MAX, -1, true> |
| 286 |
~~~~~~~~~~~~ ~~~~~~~~~~~~ |
| 287 |
Below is code that solve this problem. |
| 288 |
- ptr |
| 289 |
*/ |
| 290 |
_STLP_TEMPLATE_NULL |
| 291 |
class numeric_limits<_STLP_LONG_LONG> |
| 292 |
: public _STLP_PRIV _Numeric_limits_base<_STLP_LONG_LONG> { |
| 293 |
public: |
| 294 |
|
| 295 |
static _STLP_LONG_LONG (_STLP_CALL min) () noexcept { return LONGLONG_MIN; } |
| 296 |
static _STLP_LONG_LONG (_STLP_CALL max) () noexcept { return LONGLONG_MAX; } |
| 297 |
|
| 298 |
_STLP_STATIC_CONSTANT(int, digits = ((int)((sizeof(_STLP_LONG_LONG) * (CHAR_BIT))) - 1)); |
| 299 |
_STLP_STATIC_CONSTANT(int, digits10 = (digits * 301UL) / 1000); |
| 300 |
_STLP_STATIC_CONSTANT(int, radix = 2); |
| 301 |
_STLP_STATIC_CONSTANT(bool, is_specialized = true); |
| 302 |
_STLP_STATIC_CONSTANT(bool, is_signed = true); |
| 303 |
_STLP_STATIC_CONSTANT(bool, is_integer = true); |
| 304 |
_STLP_STATIC_CONSTANT(bool, is_exact = true); |
| 305 |
_STLP_STATIC_CONSTANT(bool, is_bounded = true); |
| 306 |
_STLP_STATIC_CONSTANT(bool, is_modulo = true); |
| 307 |
}; |
| 308 |
|
| 309 |
_STLP_TEMPLATE_NULL |
| 310 |
class numeric_limits<unsigned _STLP_LONG_LONG> |
| 311 |
: public _STLP_PRIV _Numeric_limits_base<unsigned _STLP_LONG_LONG> { |
| 312 |
public: |
| 313 |
|
| 314 |
static unsigned _STLP_LONG_LONG (_STLP_CALL min) () noexcept { return 0ULL; } |
| 315 |
static unsigned _STLP_LONG_LONG (_STLP_CALL max) () noexcept { return ULONGLONG_MAX; } |
| 316 |
|
| 317 |
_STLP_STATIC_CONSTANT(int, digits = ((int)((sizeof(unsigned _STLP_LONG_LONG) * (CHAR_BIT))))); |
| 318 |
_STLP_STATIC_CONSTANT(int, digits10 = (digits * 301UL) / 1000); |
| 319 |
_STLP_STATIC_CONSTANT(int, radix = 2); |
| 320 |
_STLP_STATIC_CONSTANT(bool, is_specialized = true); |
| 321 |
_STLP_STATIC_CONSTANT(bool, is_signed = false); |
| 322 |
_STLP_STATIC_CONSTANT(bool, is_integer = true); |
| 323 |
_STLP_STATIC_CONSTANT(bool, is_exact = true); |
| 324 |
_STLP_STATIC_CONSTANT(bool, is_bounded = true); |
| 325 |
_STLP_STATIC_CONSTANT(bool, is_modulo = true); |
| 326 |
}; |
| 327 |
|
| 328 |
# endif /* __GNUC__ > 2000-11-01 */ |
| 329 |
|
| 330 |
#endif /* _STLP_LONG_LONG */ |
| 331 |
|
| 332 |
_STLP_MOVE_TO_PRIV_NAMESPACE |
| 333 |
|
| 334 |
template <class F, int N> |
| 335 |
struct _Lim |
| 336 |
{ |
| 337 |
}; |
| 338 |
|
| 339 |
# if defined (__GNUC__) || defined (__BORLANDC__) || (defined(__SUNPRO_CC) && (__SUNPRO_CC >= 0x590)) |
| 340 |
# define _STLP_ADDITIONAL_OPEN_BRACKET { |
| 341 |
# define _STLP_ADDITIONAL_CLOSE_BRACKET } |
| 342 |
# else |
| 343 |
# define _STLP_ADDITIONAL_OPEN_BRACKET |
| 344 |
# define _STLP_ADDITIONAL_CLOSE_BRACKET |
| 345 |
# endif |
| 346 |
|
| 347 |
template <class F> |
| 348 |
struct _Lim<F,16> |
| 349 |
{ |
| 350 |
union _access |
| 351 |
{ |
| 352 |
unsigned char b[sizeof(F)]; |
| 353 |
F f; |
| 354 |
}; |
| 355 |
|
| 356 |
static F inf() noexcept |
| 357 |
{ |
| 358 |
# if defined (_STLP_BIG_ENDIAN) |
| 359 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0x7c, 0 _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 360 |
# else /* _STLP_LITTLE_ENDIAN */ |
| 361 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0, 0x7c _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 362 |
# endif |
| 363 |
return tmp.f; |
| 364 |
} |
| 365 |
|
| 366 |
static F qnan() noexcept |
| 367 |
{ |
| 368 |
# if defined (_STLP_BIG_ENDIAN) |
| 369 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0x7e, 0 _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 370 |
# else /* _STLP_LITTLE_ENDIAN */ |
| 371 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0, 0x7e _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 372 |
# endif |
| 373 |
return tmp.f; |
| 374 |
} |
| 375 |
|
| 376 |
static F snan() noexcept |
| 377 |
{ |
| 378 |
# if defined (_STLP_BIG_ENDIAN) |
| 379 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0x7d, 0 _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 380 |
# else /* _STLP_LITTLE_ENDIAN */ |
| 381 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0, 0x7d _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 382 |
# endif |
| 383 |
return tmp.f; |
| 384 |
} |
| 385 |
|
| 386 |
static F denorm_min() noexcept |
| 387 |
{ |
| 388 |
# if defined (_STLP_BIG_ENDIAN) |
| 389 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0, 0x1 _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 390 |
# else /* _STLP_LITTLE_ENDIAN */ |
| 391 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0x1, 0 _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 392 |
# endif |
| 393 |
return tmp.f; |
| 394 |
} |
| 395 |
}; |
| 396 |
|
| 397 |
template <class F> |
| 398 |
struct _Lim<F,32> |
| 399 |
{ |
| 400 |
union _access |
| 401 |
{ |
| 402 |
unsigned char b[sizeof(F)]; |
| 403 |
F f; |
| 404 |
}; |
| 405 |
|
| 406 |
static F inf() noexcept |
| 407 |
{ |
| 408 |
# if defined (_STLP_BIG_ENDIAN) |
| 409 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0x7f, 0x80, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 410 |
# else /* _STLP_LITTLE_ENDIAN */ |
| 411 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0, 0, 0x80, 0x7f _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 412 |
# endif |
| 413 |
return tmp.f; |
| 414 |
} |
| 415 |
|
| 416 |
static F qnan() noexcept |
| 417 |
{ |
| 418 |
# if defined (_STLP_BIG_ENDIAN) |
| 419 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0x7f, 0xc0, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 420 |
# else /* _STLP_LITTLE_ENDIAN */ |
| 421 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0, 0, 0xc0, 0x7f _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 422 |
# endif |
| 423 |
return tmp.f; |
| 424 |
} |
| 425 |
|
| 426 |
static F snan() noexcept |
| 427 |
{ |
| 428 |
# if defined (_STLP_BIG_ENDIAN) |
| 429 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0x7f, 0xa0, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 430 |
# else /* _STLP_LITTLE_ENDIAN */ |
| 431 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0, 0, 0xa0, 0x7f _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 432 |
# endif |
| 433 |
return tmp.f; |
| 434 |
} |
| 435 |
|
| 436 |
static F denorm_min() noexcept |
| 437 |
{ |
| 438 |
# if defined (_STLP_BIG_ENDIAN) |
| 439 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0, 0, 0, 0x1 _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 440 |
# else /* _STLP_LITTLE_ENDIAN */ |
| 441 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0x1, 0, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 442 |
# endif |
| 443 |
return tmp.f; |
| 444 |
} |
| 445 |
}; |
| 446 |
|
| 447 |
template <class F> |
| 448 |
struct _Lim<F,64> |
| 449 |
{ |
| 450 |
union _access |
| 451 |
{ |
| 452 |
unsigned char b[sizeof(F)]; |
| 453 |
F f; |
| 454 |
}; |
| 455 |
|
| 456 |
static F inf() noexcept |
| 457 |
{ |
| 458 |
# if defined (_STLP_BIG_ENDIAN) |
| 459 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 460 |
# else /* _STLP_LITTLE_ENDIAN */ |
| 461 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0, 0, 0, 0, 0, 0, 0xf0, 0x7f _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 462 |
# endif |
| 463 |
return tmp.f; |
| 464 |
} |
| 465 |
|
| 466 |
static F qnan() noexcept |
| 467 |
{ |
| 468 |
# if defined (_STLP_BIG_ENDIAN) |
| 469 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0x7f, 0xf8, 0, 0, 0, 0, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 470 |
# else /* _STLP_LITTLE_ENDIAN */ |
| 471 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0, 0, 0, 0, 0, 0, 0xf8, 0x7f _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 472 |
# endif |
| 473 |
return tmp.f; |
| 474 |
} |
| 475 |
|
| 476 |
static F snan() noexcept |
| 477 |
{ |
| 478 |
# if defined (_STLP_BIG_ENDIAN) |
| 479 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0x7f, 0xf4, 0, 0, 0, 0, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 480 |
# else /* _STLP_LITTLE_ENDIAN */ |
| 481 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0, 0, 0, 0, 0, 0, 0xf4, 0x7f _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 482 |
# endif |
| 483 |
return tmp.f; |
| 484 |
} |
| 485 |
|
| 486 |
static F denorm_min() noexcept |
| 487 |
{ |
| 488 |
# if defined (_STLP_BIG_ENDIAN) |
| 489 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0, 0, 0, 0, 0, 0, 0, 0x1 _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 490 |
# else /* _STLP_LITTLE_ENDIAN */ |
| 491 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0x1, 0, 0, 0, 0, 0, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 492 |
# endif |
| 493 |
return tmp.f; |
| 494 |
} |
| 495 |
}; |
| 496 |
|
| 497 |
template <class F> |
| 498 |
struct _Lim<F,80> |
| 499 |
{ |
| 500 |
union _access |
| 501 |
{ |
| 502 |
unsigned char b[sizeof(F)]; |
| 503 |
F f; |
| 504 |
}; |
| 505 |
|
| 506 |
static F inf() noexcept |
| 507 |
{ |
| 508 |
# if defined (_STLP_BIG_ENDIAN) |
| 509 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0x7f, 0xff, 0, 0, 0, 0, 0, 0, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 510 |
# else /* _STLP_LITTLE_ENDIAN */ |
| 511 |
# if defined(__i386__) || defined(__ia64__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_IA64) || defined(_M_AMD64) |
| 512 |
/* For historical reasons, this format has no implicit/hidden bit: the explicit bit |
| 513 |
was used in the Intel 8087 to suppress the normalization of subnormal numbers in |
| 514 |
certain cases. |
| 515 |
*/ |
| 516 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0, 0, 0, 0, 0, 0, 0, 0x80, 0xff, 0x7f _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 517 |
# else |
| 518 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0x7f _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 519 |
# endif |
| 520 |
# endif |
| 521 |
return tmp.f; |
| 522 |
} |
| 523 |
|
| 524 |
static F qnan() noexcept |
| 525 |
{ |
| 526 |
# if defined (_STLP_BIG_ENDIAN) |
| 527 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0x7f, 0xff, 0x80, 0, 0, 0, 0, 0, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 528 |
# else /* _STLP_LITTLE_ENDIAN */ |
| 529 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0, 0, 0, 0, 0, 0, 0, 0x80, 0xff, 0x7f _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 530 |
# endif |
| 531 |
return tmp.f; |
| 532 |
} |
| 533 |
|
| 534 |
static F snan() noexcept |
| 535 |
{ |
| 536 |
# if defined (_STLP_BIG_ENDIAN) |
| 537 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0x7f, 0xff, 0x40, 0, 0, 0, 0, 0, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 538 |
# else /* _STLP_LITTLE_ENDIAN */ |
| 539 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0, 0, 0, 0, 0, 0, 0, 0x40, 0xff, 0x7f _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 540 |
# endif |
| 541 |
return tmp.f; |
| 542 |
} |
| 543 |
|
| 544 |
static F denorm_min() noexcept |
| 545 |
{ |
| 546 |
# if defined (_STLP_BIG_ENDIAN) |
| 547 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1 _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 548 |
# else /* _STLP_LITTLE_ENDIAN */ |
| 549 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 550 |
# endif |
| 551 |
return tmp.f; |
| 552 |
} |
| 553 |
}; |
| 554 |
|
| 555 |
template <class F> |
| 556 |
struct _Lim<F,96> |
| 557 |
{ |
| 558 |
union _access |
| 559 |
{ |
| 560 |
unsigned char b[sizeof(F)]; |
| 561 |
F f; |
| 562 |
}; |
| 563 |
|
| 564 |
static F inf() noexcept |
| 565 |
{ |
| 566 |
# if defined (_STLP_BIG_ENDIAN) |
| 567 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0x7f, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 568 |
# else /* _STLP_LITTLE_ENDIAN */ |
| 569 |
# if defined(__i386__) || defined(__ia64__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_IA64) || defined(_M_AMD64) |
| 570 |
/* This is same format as 80-bits above, just take into account alignment (padded |
| 571 |
by empty bytes). |
| 572 |
For historical reasons, this format has no implicit/hidden bit: the explicit bit |
| 573 |
was used in the Intel 8087 to suppress the normalization of subnormal numbers in |
| 574 |
certain cases. |
| 575 |
*/ |
| 576 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0, 0, 0, 0, 0, 0, 0, 0x80, 0xff, 0x7f, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 577 |
# else |
| 578 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0x7f, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 579 |
# endif |
| 580 |
# endif |
| 581 |
return tmp.f; |
| 582 |
} |
| 583 |
|
| 584 |
static F qnan() noexcept |
| 585 |
{ |
| 586 |
# if defined (_STLP_BIG_ENDIAN) |
| 587 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0x7f, 0xff, 0, 0, 0xc0, 0, 0, 0, 0, 0, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 588 |
# else /* _STLP_LITTLE_ENDIAN */ |
| 589 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0, 0, 0, 0, 0, 0, 0, 0xc0, 0xff, 0x7f, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 590 |
# endif |
| 591 |
return tmp.f; |
| 592 |
} |
| 593 |
|
| 594 |
static F snan() noexcept |
| 595 |
{ |
| 596 |
# if defined (_STLP_BIG_ENDIAN) |
| 597 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0x7f, 0xff, 0, 0, 0xa0, 0, 0, 0, 0, 0, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 598 |
# else /* _STLP_LITTLE_ENDIAN */ |
| 599 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0, 0, 0, 0, 0, 0, 0, 0xa0, 0xff, 0x7f, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 600 |
# endif |
| 601 |
return tmp.f; |
| 602 |
} |
| 603 |
|
| 604 |
static F denorm_min() noexcept |
| 605 |
{ |
| 606 |
# if defined (_STLP_BIG_ENDIAN) |
| 607 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1 _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 608 |
# else /* _STLP_LITTLE_ENDIAN */ |
| 609 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 610 |
# endif |
| 611 |
return tmp.f; |
| 612 |
} |
| 613 |
}; |
| 614 |
|
| 615 |
template <class F> |
| 616 |
struct _Lim<F,128> |
| 617 |
{ |
| 618 |
union _access |
| 619 |
{ |
| 620 |
unsigned char b[sizeof(F)]; |
| 621 |
F f; |
| 622 |
}; |
| 623 |
|
| 624 |
static F inf() noexcept |
| 625 |
{ |
| 626 |
# if defined (_STLP_BIG_ENDIAN) |
| 627 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0x7f, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 628 |
# else /* _STLP_LITTLE_ENDIAN */ |
| 629 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0x7f, 0, 0, 0, 0, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 630 |
# endif |
| 631 |
return tmp.f; |
| 632 |
} |
| 633 |
|
| 634 |
static F qnan() noexcept |
| 635 |
{ |
| 636 |
# if defined (_STLP_BIG_ENDIAN) |
| 637 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0x7f, 0xff, 0, 0, 0, 0, 0xc0, 0, 0, 0, 0, 0, 0, 0, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 638 |
# else /* _STLP_LITTLE_ENDIAN */ |
| 639 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0, 0, 0, 0, 0, 0, 0, 0xc0, 0xff, 0x7f, 0, 0, 0, 0, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 640 |
# endif |
| 641 |
return tmp.f; |
| 642 |
} |
| 643 |
|
| 644 |
static F snan() noexcept |
| 645 |
{ |
| 646 |
# if defined (_STLP_BIG_ENDIAN) |
| 647 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0x7f, 0xff, 0, 0, 0, 0, 0xa0, 0, 0, 0, 0, 0, 0, 0, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 648 |
# else /* _STLP_LITTLE_ENDIAN */ |
| 649 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0, 0, 0, 0, 0, 0, 0, 0xa0, 0xff, 0x7f, 0, 0, 0, 0, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 650 |
# endif |
| 651 |
return tmp.f; |
| 652 |
} |
| 653 |
|
| 654 |
static F denorm_min() noexcept |
| 655 |
{ |
| 656 |
# if defined (_STLP_BIG_ENDIAN) |
| 657 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x1, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 658 |
# else /* _STLP_LITTLE_ENDIAN */ |
| 659 |
_access tmp = { _STLP_ADDITIONAL_OPEN_BRACKET 0x1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 _STLP_ADDITIONAL_CLOSE_BRACKET }; |
| 660 |
# endif |
| 661 |
return tmp.f; |
| 662 |
} |
| 663 |
}; |
| 664 |
|
| 665 |
#undef _STLP_ADDITIONAL_OPEN_BRACKET |
| 666 |
#undef _STLP_ADDITIONAL_CLOSE_BRACKET |
| 667 |
|
| 668 |
#if defined (__GNUC__) |
| 669 |
# if defined (__FLT_DENORM_MIN__) |
| 670 |
# define _STLP_FLT_DENORM_MIN __FLT_DENORM_MIN__ |
| 671 |
# else |
| 672 |
# define _STLP_FLT_DENORM_STYLE denorm_absent |
| 673 |
# endif |
| 674 |
# if defined (__DBL_DENORM_MIN__) |
| 675 |
# define _STLP_DBL_DENORM_MIN __DBL_DENORM_MIN__ |
| 676 |
# else |
| 677 |
# define _STLP_DBL_DENORM_STYLE denorm_absent |
| 678 |
# endif |
| 679 |
# if defined (__LDBL_DENORM_MIN__) |
| 680 |
# define _STLP_LDBL_DENORM_MIN __LDBL_DENORM_MIN__ |
| 681 |
# else |
| 682 |
# define _STLP_LDBL_DENORM_STYLE denorm_absent |
| 683 |
# endif |
| 684 |
#endif |
| 685 |
|
| 686 |
/* If compiler do not expose thanks to some macro its status regarding |
| 687 |
* denormalized floating point numbers, we consider that denormalization |
| 688 |
* is present. Unit tests will tell us if compiler do not support them. */ |
| 689 |
#if !defined (_STLP_FLT_DENORM_STYLE) |
| 690 |
# define _STLP_FLT_DENORM_STYLE denorm_present |
| 691 |
#endif |
| 692 |
|
| 693 |
#if !defined (_STLP_DBL_DENORM_STYLE) |
| 694 |
# define _STLP_DBL_DENORM_STYLE denorm_present |
| 695 |
#endif |
| 696 |
|
| 697 |
#if !defined (_STLP_LDBL_DENORM_STYLE) |
| 698 |
# define _STLP_LDBL_DENORM_STYLE denorm_present |
| 699 |
#endif |
| 700 |
|
| 701 |
_STLP_MOVE_TO_STD_NAMESPACE |
| 702 |
|
| 703 |
_STLP_TEMPLATE_NULL |
| 704 |
class numeric_limits<float> : |
| 705 |
public _STLP_PRIV _Floating_limits<float, |
| 706 |
FLT_MANT_DIG, // Binary digits of precision |
| 707 |
FLT_DIG, // Decimal digits of precision |
| 708 |
FLT_MIN_EXP, // Minimum exponent |
| 709 |
FLT_MAX_EXP, // Maximum exponent |
| 710 |
FLT_MIN_10_EXP, // Minimum base 10 exponent |
| 711 |
FLT_MAX_10_EXP, // Maximum base 10 exponent |
| 712 |
true, |
| 713 |
_STLP_FLT_DENORM_STYLE, |
| 714 |
round_to_nearest> |
| 715 |
{ |
| 716 |
public: |
| 717 |
static float (_STLP_CALL min) () noexcept { return FLT_MIN; } |
| 718 |
static float _STLP_CALL denorm_min() noexcept |
| 719 |
{ |
| 720 |
#if defined (_STLP_FLT_DENORM_MIN) |
| 721 |
return _STLP_FLT_DENORM_MIN; |
| 722 |
#else |
| 723 |
return _STLP_FLT_DENORM_STYLE ? _STLP_PRIV _Lim<float,sizeof(float)<<3>::denorm_min() : FLT_MIN; |
| 724 |
#endif |
| 725 |
} |
| 726 |
static float (_STLP_CALL max) () noexcept |
| 727 |
{ return FLT_MAX; } |
| 728 |
static float _STLP_CALL epsilon() noexcept |
| 729 |
{ return FLT_EPSILON; } |
| 730 |
static float _STLP_CALL round_error() noexcept |
| 731 |
{ return 0.5f; } // Units: ulps. |
| 732 |
static float _STLP_CALL infinity() noexcept |
| 733 |
{ return _STLP_PRIV _Lim<float,sizeof(float)<<3>::inf(); } |
| 734 |
static float _STLP_CALL quiet_NaN() noexcept |
| 735 |
{ return _STLP_PRIV _Lim<float,sizeof(float)<<3>::qnan(); } |
| 736 |
static float _STLP_CALL signaling_NaN() noexcept |
| 737 |
{ return _STLP_PRIV _Lim<float,sizeof(float)<<3>::snan(); } |
| 738 |
}; |
| 739 |
|
| 740 |
#undef _STLP_FLT_DENORM_MIN |
| 741 |
#undef _STLP_FLT_DNORM_STYLE |
| 742 |
|
| 743 |
_STLP_TEMPLATE_NULL |
| 744 |
class numeric_limits<double> : |
| 745 |
public _STLP_PRIV _Floating_limits<double, |
| 746 |
DBL_MANT_DIG, // Binary digits of precision |
| 747 |
DBL_DIG, // Decimal digits of precision |
| 748 |
DBL_MIN_EXP, // Minimum exponent |
| 749 |
DBL_MAX_EXP, // Maximum exponent |
| 750 |
DBL_MIN_10_EXP, // Minimum base 10 exponent |
| 751 |
DBL_MAX_10_EXP, // Maximum base 10 exponent |
| 752 |
true, |
| 753 |
_STLP_DBL_DENORM_STYLE, |
| 754 |
round_to_nearest> |
| 755 |
{ |
| 756 |
public: |
| 757 |
static double (_STLP_CALL min)() noexcept |
| 758 |
{ return DBL_MIN; } |
| 759 |
static double _STLP_CALL denorm_min() noexcept |
| 760 |
{ |
| 761 |
#if defined (_STLP_DBL_DENORM_MIN) |
| 762 |
return _STLP_DBL_DENORM_MIN; |
| 763 |
#else |
| 764 |
return _STLP_DBL_DENORM_STYLE ? _STLP_PRIV _Lim<double,sizeof(double)<<3>::denorm_min() : DBL_MIN; |
| 765 |
#endif |
| 766 |
} |
| 767 |
static double (_STLP_CALL max)() noexcept |
| 768 |
{ return DBL_MAX; } |
| 769 |
static double _STLP_CALL epsilon() noexcept |
| 770 |
{ return DBL_EPSILON; } |
| 771 |
static double _STLP_CALL round_error() noexcept |
| 772 |
{ return 0.5; } // Units: ulps. |
| 773 |
static double _STLP_CALL infinity() noexcept |
| 774 |
{ return _STLP_PRIV _Lim<double,sizeof(double)<<3>::inf(); } |
| 775 |
static double _STLP_CALL quiet_NaN() noexcept |
| 776 |
{ return _STLP_PRIV _Lim<double,sizeof(double)<<3>::qnan(); } |
| 777 |
static double _STLP_CALL signaling_NaN() noexcept |
| 778 |
{ return _STLP_PRIV _Lim<double,sizeof(double)<<3>::snan(); } |
| 779 |
}; |
| 780 |
|
| 781 |
#if !defined (_STLP_NO_LONG_DOUBLE) |
| 782 |
|
| 783 |
_STLP_TEMPLATE_NULL |
| 784 |
class numeric_limits<long double> : |
| 785 |
public _STLP_PRIV _Floating_limits<long double, |
| 786 |
LDBL_MANT_DIG, // Binary digits of precision |
| 787 |
LDBL_DIG, // Decimal digits of precision |
| 788 |
LDBL_MIN_EXP, // Minimum exponent |
| 789 |
LDBL_MAX_EXP, // Maximum exponent |
| 790 |
LDBL_MIN_10_EXP,// Minimum base 10 exponent |
| 791 |
LDBL_MAX_10_EXP,// Maximum base 10 exponent |
| 792 |
false, // do not conform to iec559 |
| 793 |
_STLP_LDBL_DENORM_STYLE, |
| 794 |
round_to_nearest> |
| 795 |
{ |
| 796 |
public: |
| 797 |
static long double (_STLP_CALL min) () noexcept |
| 798 |
{ return LDBL_MIN; } |
| 799 |
static long double _STLP_CALL denorm_min() noexcept |
| 800 |
{ |
| 801 |
#if defined (_STLP_LDBL_DENORM_MIN) |
| 802 |
return _STLP_LDBL_DENORM_MIN; |
| 803 |
#else |
| 804 |
return _STLP_LDBL_DENORM_STYLE ? _STLP_PRIV _Lim<long double,sizeof(long double)<<3>::denorm_min() : LDBL_MIN; |
| 805 |
#endif |
| 806 |
} |
| 807 |
_STLP_STATIC_CONSTANT(bool, is_iec559 = false); |
| 808 |
static long double (_STLP_CALL max) () noexcept |
| 809 |
{ return LDBL_MAX; } |
| 810 |
static long double _STLP_CALL epsilon() noexcept |
| 811 |
{ return LDBL_EPSILON; } |
| 812 |
static long double _STLP_CALL round_error() noexcept |
| 813 |
{ return 0.5l; } |
| 814 |
static long double _STLP_CALL infinity() noexcept |
| 815 |
{ |
| 816 |
return _STLP_PRIV _Lim<long double,sizeof(long double)<<3>::inf(); |
| 817 |
} |
| 818 |
static long double _STLP_CALL quiet_NaN() noexcept |
| 819 |
{ return _STLP_PRIV _Lim<long double,sizeof(long double)<<3>::qnan(); } |
| 820 |
static long double _STLP_CALL signaling_NaN() noexcept |
| 821 |
{ return _STLP_PRIV _Lim<long double,sizeof(long double)<<3>::snan(); } |
| 822 |
}; |
| 823 |
|
| 824 |
#endif |
| 825 |
|
| 826 |
// We write special values (Inf and NaN) as bit patterns and |
| 827 |
// cast the the appropriate floating-point types. |
| 828 |
_STLP_END_NAMESPACE |
| 829 |
|
| 830 |
//========================================================== |
| 831 |
// numeric_limits static members |
| 832 |
//========================================================== |
| 833 |
|
| 834 |
_STLP_BEGIN_NAMESPACE |
| 835 |
|
| 836 |
_STLP_MOVE_TO_PRIV_NAMESPACE |
| 837 |
|
| 838 |
#if !defined (_STLP_STATIC_CONST_INIT_BUG) && !defined (_STLP_NO_STATIC_CONST_DEFINITION) |
| 839 |
|
| 840 |
# define __declare_numeric_base_member(__type, __mem) \ |
| 841 |
template <class __number> \ |
| 842 |
const __type _Numeric_limits_base<__number>:: __mem |
| 843 |
|
| 844 |
__declare_numeric_base_member(bool, is_specialized); |
| 845 |
__declare_numeric_base_member(int, digits); |
| 846 |
__declare_numeric_base_member(int, digits10); |
| 847 |
__declare_numeric_base_member(bool, is_signed); |
| 848 |
__declare_numeric_base_member(bool, is_integer); |
| 849 |
__declare_numeric_base_member(bool, is_exact); |
| 850 |
__declare_numeric_base_member(int, radix); |
| 851 |
__declare_numeric_base_member(int, min_exponent); |
| 852 |
__declare_numeric_base_member(int, max_exponent); |
| 853 |
__declare_numeric_base_member(int, min_exponent10); |
| 854 |
__declare_numeric_base_member(int, max_exponent10); |
| 855 |
__declare_numeric_base_member(bool, has_infinity); |
| 856 |
__declare_numeric_base_member(bool, has_quiet_NaN); |
| 857 |
__declare_numeric_base_member(bool, has_signaling_NaN); |
| 858 |
__declare_numeric_base_member(float_denorm_style, has_denorm); |
| 859 |
__declare_numeric_base_member(bool, has_denorm_loss); |
| 860 |
__declare_numeric_base_member(bool, is_iec559); |
| 861 |
__declare_numeric_base_member(bool, is_bounded); |
| 862 |
__declare_numeric_base_member(bool, is_modulo); |
| 863 |
__declare_numeric_base_member(bool, traps); |
| 864 |
__declare_numeric_base_member(bool, tinyness_before); |
| 865 |
__declare_numeric_base_member(float_round_style, round_style); |
| 866 |
|
| 867 |
# undef __declare_numeric_base_member |
| 868 |
|
| 869 |
# define __declare_integer_limits_member(__type, __mem) \ |
| 870 |
template <class _Int, _STLP_LIMITS_MIN_TYPE __imin, _STLP_LIMITS_MAX_TYPE __imax, int __idigits, bool __ismod> \ |
| 871 |
const __type _Integer_limits<_Int, __imin, __imax, __idigits, __ismod>:: __mem |
| 872 |
|
| 873 |
__declare_integer_limits_member(bool, is_specialized); |
| 874 |
__declare_integer_limits_member(int, digits); |
| 875 |
__declare_integer_limits_member(int, digits10); |
| 876 |
__declare_integer_limits_member(bool, is_signed); |
| 877 |
__declare_integer_limits_member(bool, is_integer); |
| 878 |
__declare_integer_limits_member(bool, is_exact); |
| 879 |
__declare_integer_limits_member(int, radix); |
| 880 |
__declare_integer_limits_member(bool, is_bounded); |
| 881 |
__declare_integer_limits_member(bool, is_modulo); |
| 882 |
# undef __declare_integer_limits_member |
| 883 |
|
| 884 |
# if defined (__GNUC__) && (__GNUC__ != 2 || __GNUC_MINOR__ > 96) && (__GNUC__ != 3 || __GNUC_MINOR__ == 0) && (__GNUC__ <= 3) |
| 885 |
_STLP_MOVE_TO_STD_NAMESPACE |
| 886 |
|
| 887 |
# define __declare_numeric_limits_member(__integer) \ |
| 888 |
_STLP_TEMPLATE_NULL const int numeric_limits<__integer>::digits; \ |
| 889 |
_STLP_TEMPLATE_NULL const int numeric_limits<__integer>::digits10; \ |
| 890 |
_STLP_TEMPLATE_NULL const int numeric_limits<__integer>::radix; \ |
| 891 |
_STLP_TEMPLATE_NULL const bool numeric_limits<__integer>::is_specialized; \ |
| 892 |
_STLP_TEMPLATE_NULL const bool numeric_limits<__integer>::is_signed; \ |
| 893 |
_STLP_TEMPLATE_NULL const bool numeric_limits<__integer>::is_integer; \ |
| 894 |
_STLP_TEMPLATE_NULL const bool numeric_limits<__integer>::is_exact; \ |
| 895 |
_STLP_TEMPLATE_NULL const bool numeric_limits<__integer>::is_bounded; \ |
| 896 |
_STLP_TEMPLATE_NULL const bool numeric_limits<__integer>::is_modulo |
| 897 |
|
| 898 |
__declare_numeric_limits_member(_STLP_LONG_LONG); |
| 899 |
__declare_numeric_limits_member(unsigned _STLP_LONG_LONG); |
| 900 |
|
| 901 |
# undef __declare_numeric_limits_member |
| 902 |
|
| 903 |
_STLP_MOVE_TO_PRIV_NAMESPACE |
| 904 |
# endif |
| 905 |
|
| 906 |
# define __declare_float_limits_member(__type, __mem) \ |
| 907 |
template <class __number, \ |
| 908 |
int __Digits, int __Digits10, \ |
| 909 |
int __MinExp, int __MaxExp, \ |
| 910 |
int __MinExp10, int __MaxExp10, \ |
| 911 |
bool __IsIEC559, \ |
| 912 |
float_denorm_style __DenormStyle, \ |
| 913 |
float_round_style __RoundStyle> \ |
| 914 |
const __type _Floating_limits< __number, __Digits, __Digits10, \ |
| 915 |
__MinExp, __MaxExp, __MinExp10, __MaxExp10, \ |
| 916 |
__IsIEC559, __DenormStyle, __RoundStyle>::\ |
| 917 |
__mem |
| 918 |
|
| 919 |
__declare_float_limits_member(bool, is_specialized); |
| 920 |
__declare_float_limits_member(int, digits); |
| 921 |
__declare_float_limits_member(int, digits10); |
| 922 |
__declare_float_limits_member(bool, is_signed); |
| 923 |
__declare_float_limits_member(int, radix); |
| 924 |
__declare_float_limits_member(int, min_exponent); |
| 925 |
__declare_float_limits_member(int, max_exponent); |
| 926 |
__declare_float_limits_member(int, min_exponent10); |
| 927 |
__declare_float_limits_member(int, max_exponent10); |
| 928 |
__declare_float_limits_member(bool, has_infinity); |
| 929 |
__declare_float_limits_member(bool, has_quiet_NaN); |
| 930 |
__declare_float_limits_member(bool, has_signaling_NaN); |
| 931 |
__declare_float_limits_member(float_denorm_style, has_denorm); |
| 932 |
__declare_float_limits_member(bool, has_denorm_loss); |
| 933 |
__declare_float_limits_member(bool, is_iec559); |
| 934 |
__declare_float_limits_member(bool, is_bounded); |
| 935 |
__declare_float_limits_member(bool, traps); |
| 936 |
__declare_float_limits_member(bool, tinyness_before); |
| 937 |
__declare_float_limits_member(float_round_style, round_style); |
| 938 |
# undef __declare_float_limits_member |
| 939 |
|
| 940 |
#endif |
| 941 |
|
| 942 |
#undef _STLP_LIMITS_MIN_TYPE |
| 943 |
#undef _STLP_LIMITS_MAX_TYPE |
| 944 |
|
| 945 |
_STLP_MOVE_TO_STD_NAMESPACE |
| 946 |
|
| 947 |
_STLP_END_NAMESPACE |
| 948 |
|
| 949 |
#if (_STLP_OUTERMOST_HEADER_ID == 0x39) |
| 950 |
# include <stl/_epilog.h> |
| 951 |
# undef _STLP_OUTERMOST_HEADER_ID |
| 952 |
#endif |
| 953 |
|
| 954 |
#endif /* _STLP_LIMITS */ |
| 955 |
|
| 956 |
// Local Variables: |
| 957 |
// mode:C++ |
| 958 |
// End: |