sl@0
|
1 |
// Copyright 2001 John Maddock
|
sl@0
|
2 |
// Distributed under the Boost Software License, Version 1.0. (See accompany-
|
sl@0
|
3 |
// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
sl@0
|
4 |
|
sl@0
|
5 |
/*
|
sl@0
|
6 |
* Copyright (c) 1997
|
sl@0
|
7 |
* Silicon Graphics Computer Systems, Inc.
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Permission to use, copy, modify, distribute and sell this software
|
sl@0
|
10 |
* and its documentation for any purpose is hereby granted without fee,
|
sl@0
|
11 |
* provided that the above copyright notice appear in all copies and
|
sl@0
|
12 |
* that both that copyright notice and this permission notice appear
|
sl@0
|
13 |
* in supporting documentation. Silicon Graphics makes no
|
sl@0
|
14 |
* representations about the suitability of this software for any
|
sl@0
|
15 |
* purpose. It is provided "as is" without express or implied warranty.
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
/* NOTE: This is not portable code. Parts of numeric_limits<> are
|
sl@0
|
19 |
* inherently machine-dependent, and this file is written for the MIPS
|
sl@0
|
20 |
* architecture and the SGI MIPSpro C++ compiler. Parts of it (in
|
sl@0
|
21 |
* particular, some of the characteristics of floating-point types)
|
sl@0
|
22 |
* are almost certainly incorrect for any other platform.
|
sl@0
|
23 |
*/
|
sl@0
|
24 |
|
sl@0
|
25 |
/* The above comment is almost certainly out of date. This file works
|
sl@0
|
26 |
* on systems other than SGI MIPSpro C++ now.
|
sl@0
|
27 |
*/
|
sl@0
|
28 |
|
sl@0
|
29 |
/*
|
sl@0
|
30 |
* Revision history:
|
sl@0
|
31 |
* 21 Sep 2001:
|
sl@0
|
32 |
* Only include <cwchar> if BOOST_NO_CWCHAR is defined. (Darin Adler)
|
sl@0
|
33 |
* 10 Aug 2001:
|
sl@0
|
34 |
* Added MIPS (big endian) to the big endian family. (Jens Maurer)
|
sl@0
|
35 |
* 13 Apr 2001:
|
sl@0
|
36 |
* Added powerpc to the big endian family. (Jeremy Siek)
|
sl@0
|
37 |
* 5 Apr 2001:
|
sl@0
|
38 |
* Added sparc (big endian) processor support (John Maddock).
|
sl@0
|
39 |
* Initial sub:
|
sl@0
|
40 |
* Modified by Jens Maurer for gcc 2.95 on x86.
|
sl@0
|
41 |
*/
|
sl@0
|
42 |
|
sl@0
|
43 |
#ifndef BOOST_SGI_CPP_LIMITS
|
sl@0
|
44 |
#define BOOST_SGI_CPP_LIMITS
|
sl@0
|
45 |
|
sl@0
|
46 |
#include <climits>
|
sl@0
|
47 |
#include <cfloat>
|
sl@0
|
48 |
#include <boost/config.hpp>
|
sl@0
|
49 |
#include <boost/detail/endian.hpp>
|
sl@0
|
50 |
|
sl@0
|
51 |
#ifndef BOOST_NO_CWCHAR
|
sl@0
|
52 |
#include <cwchar> // for WCHAR_MIN and WCHAR_MAX
|
sl@0
|
53 |
#endif
|
sl@0
|
54 |
|
sl@0
|
55 |
namespace std {
|
sl@0
|
56 |
|
sl@0
|
57 |
enum float_round_style {
|
sl@0
|
58 |
round_indeterminate = -1,
|
sl@0
|
59 |
round_toward_zero = 0,
|
sl@0
|
60 |
round_to_nearest = 1,
|
sl@0
|
61 |
round_toward_infinity = 2,
|
sl@0
|
62 |
round_toward_neg_infinity = 3
|
sl@0
|
63 |
};
|
sl@0
|
64 |
|
sl@0
|
65 |
enum float_denorm_style {
|
sl@0
|
66 |
denorm_indeterminate = -1,
|
sl@0
|
67 |
denorm_absent = 0,
|
sl@0
|
68 |
denorm_present = 1
|
sl@0
|
69 |
};
|
sl@0
|
70 |
|
sl@0
|
71 |
// The C++ standard (section 18.2.1) requires that some of the members of
|
sl@0
|
72 |
// numeric_limits be static const data members that are given constant-
|
sl@0
|
73 |
// initializers within the class declaration. On compilers where the
|
sl@0
|
74 |
// BOOST_NO_INCLASS_MEMBER_INITIALIZATION macro is defined, it is impossible to write
|
sl@0
|
75 |
// a standard-conforming numeric_limits class.
|
sl@0
|
76 |
//
|
sl@0
|
77 |
// There are two possible workarounds: either initialize the data
|
sl@0
|
78 |
// members outside the class, or change them from data members to
|
sl@0
|
79 |
// enums. Neither workaround is satisfactory: the former makes it
|
sl@0
|
80 |
// impossible to use the data members in constant-expressions, and the
|
sl@0
|
81 |
// latter means they have the wrong type and that it is impossible to
|
sl@0
|
82 |
// take their addresses. We choose the former workaround.
|
sl@0
|
83 |
|
sl@0
|
84 |
#ifdef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
|
sl@0
|
85 |
# define BOOST_STL_DECLARE_LIMITS_MEMBER(__mem_type, __mem_name, __mem_value) \
|
sl@0
|
86 |
enum { __mem_name = __mem_value }
|
sl@0
|
87 |
#else /* BOOST_NO_INCLASS_MEMBER_INITIALIZATION */
|
sl@0
|
88 |
# define BOOST_STL_DECLARE_LIMITS_MEMBER(__mem_type, __mem_name, __mem_value) \
|
sl@0
|
89 |
static const __mem_type __mem_name = __mem_value
|
sl@0
|
90 |
#endif /* BOOST_NO_INCLASS_MEMBER_INITIALIZATION */
|
sl@0
|
91 |
|
sl@0
|
92 |
// Base class for all specializations of numeric_limits.
|
sl@0
|
93 |
template <class __number>
|
sl@0
|
94 |
class _Numeric_limits_base {
|
sl@0
|
95 |
public:
|
sl@0
|
96 |
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_specialized, false);
|
sl@0
|
97 |
|
sl@0
|
98 |
static __number min BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return __number(); }
|
sl@0
|
99 |
static __number max BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return __number(); }
|
sl@0
|
100 |
|
sl@0
|
101 |
BOOST_STL_DECLARE_LIMITS_MEMBER(int, digits, 0);
|
sl@0
|
102 |
BOOST_STL_DECLARE_LIMITS_MEMBER(int, digits10, 0);
|
sl@0
|
103 |
|
sl@0
|
104 |
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_signed, false);
|
sl@0
|
105 |
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_integer, false);
|
sl@0
|
106 |
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_exact, false);
|
sl@0
|
107 |
|
sl@0
|
108 |
BOOST_STL_DECLARE_LIMITS_MEMBER(int, radix, 0);
|
sl@0
|
109 |
|
sl@0
|
110 |
static __number epsilon() throw() { return __number(); }
|
sl@0
|
111 |
static __number round_error() throw() { return __number(); }
|
sl@0
|
112 |
|
sl@0
|
113 |
BOOST_STL_DECLARE_LIMITS_MEMBER(int, min_exponent, 0);
|
sl@0
|
114 |
BOOST_STL_DECLARE_LIMITS_MEMBER(int, min_exponent10, 0);
|
sl@0
|
115 |
BOOST_STL_DECLARE_LIMITS_MEMBER(int, max_exponent, 0);
|
sl@0
|
116 |
BOOST_STL_DECLARE_LIMITS_MEMBER(int, max_exponent10, 0);
|
sl@0
|
117 |
|
sl@0
|
118 |
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, has_infinity, false);
|
sl@0
|
119 |
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, has_quiet_NaN, false);
|
sl@0
|
120 |
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, has_signaling_NaN, false);
|
sl@0
|
121 |
BOOST_STL_DECLARE_LIMITS_MEMBER(float_denorm_style,
|
sl@0
|
122 |
has_denorm,
|
sl@0
|
123 |
denorm_absent);
|
sl@0
|
124 |
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, has_denorm_loss, false);
|
sl@0
|
125 |
|
sl@0
|
126 |
static __number infinity() throw() { return __number(); }
|
sl@0
|
127 |
static __number quiet_NaN() throw() { return __number(); }
|
sl@0
|
128 |
static __number signaling_NaN() throw() { return __number(); }
|
sl@0
|
129 |
static __number denorm_min() throw() { return __number(); }
|
sl@0
|
130 |
|
sl@0
|
131 |
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_iec559, false);
|
sl@0
|
132 |
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_bounded, false);
|
sl@0
|
133 |
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_modulo, false);
|
sl@0
|
134 |
|
sl@0
|
135 |
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, traps, false);
|
sl@0
|
136 |
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, tinyness_before, false);
|
sl@0
|
137 |
BOOST_STL_DECLARE_LIMITS_MEMBER(float_round_style,
|
sl@0
|
138 |
round_style,
|
sl@0
|
139 |
round_toward_zero);
|
sl@0
|
140 |
};
|
sl@0
|
141 |
|
sl@0
|
142 |
// Base class for integers.
|
sl@0
|
143 |
|
sl@0
|
144 |
template <class _Int,
|
sl@0
|
145 |
_Int __imin,
|
sl@0
|
146 |
_Int __imax,
|
sl@0
|
147 |
int __idigits = -1>
|
sl@0
|
148 |
class _Integer_limits : public _Numeric_limits_base<_Int>
|
sl@0
|
149 |
{
|
sl@0
|
150 |
public:
|
sl@0
|
151 |
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_specialized, true);
|
sl@0
|
152 |
|
sl@0
|
153 |
static _Int min BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return __imin; }
|
sl@0
|
154 |
static _Int max BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return __imax; }
|
sl@0
|
155 |
|
sl@0
|
156 |
BOOST_STL_DECLARE_LIMITS_MEMBER(int,
|
sl@0
|
157 |
digits,
|
sl@0
|
158 |
(__idigits < 0) ? (int)(sizeof(_Int) * CHAR_BIT)
|
sl@0
|
159 |
- (__imin == 0 ? 0 : 1)
|
sl@0
|
160 |
: __idigits);
|
sl@0
|
161 |
BOOST_STL_DECLARE_LIMITS_MEMBER(int, digits10, (digits * 301) / 1000);
|
sl@0
|
162 |
// log 2 = 0.301029995664...
|
sl@0
|
163 |
|
sl@0
|
164 |
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_signed, __imin != 0);
|
sl@0
|
165 |
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_integer, true);
|
sl@0
|
166 |
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_exact, true);
|
sl@0
|
167 |
BOOST_STL_DECLARE_LIMITS_MEMBER(int, radix, 2);
|
sl@0
|
168 |
|
sl@0
|
169 |
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_bounded, true);
|
sl@0
|
170 |
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_modulo, true);
|
sl@0
|
171 |
};
|
sl@0
|
172 |
|
sl@0
|
173 |
#if defined(BOOST_BIG_ENDIAN)
|
sl@0
|
174 |
|
sl@0
|
175 |
template<class Number, unsigned int Word>
|
sl@0
|
176 |
struct float_helper{
|
sl@0
|
177 |
static Number get_word() throw() {
|
sl@0
|
178 |
// sizeof(long double) == 16
|
sl@0
|
179 |
const unsigned int _S_word[4] = { Word, 0, 0, 0 };
|
sl@0
|
180 |
return *reinterpret_cast<const Number*>(&_S_word);
|
sl@0
|
181 |
}
|
sl@0
|
182 |
};
|
sl@0
|
183 |
|
sl@0
|
184 |
#else
|
sl@0
|
185 |
|
sl@0
|
186 |
template<class Number, unsigned int Word>
|
sl@0
|
187 |
struct float_helper{
|
sl@0
|
188 |
static Number get_word() throw() {
|
sl@0
|
189 |
// sizeof(long double) == 12, but only 10 bytes significant
|
sl@0
|
190 |
const unsigned int _S_word[4] = { 0, 0, 0, Word };
|
sl@0
|
191 |
return *reinterpret_cast<const Number*>(
|
sl@0
|
192 |
reinterpret_cast<const char *>(&_S_word)+16-
|
sl@0
|
193 |
(sizeof(Number) == 12 ? 10 : sizeof(Number)));
|
sl@0
|
194 |
}
|
sl@0
|
195 |
};
|
sl@0
|
196 |
|
sl@0
|
197 |
#endif
|
sl@0
|
198 |
|
sl@0
|
199 |
// Base class for floating-point numbers.
|
sl@0
|
200 |
template <class __number,
|
sl@0
|
201 |
int __Digits, int __Digits10,
|
sl@0
|
202 |
int __MinExp, int __MaxExp,
|
sl@0
|
203 |
int __MinExp10, int __MaxExp10,
|
sl@0
|
204 |
unsigned int __InfinityWord,
|
sl@0
|
205 |
unsigned int __QNaNWord, unsigned int __SNaNWord,
|
sl@0
|
206 |
bool __IsIEC559,
|
sl@0
|
207 |
float_round_style __RoundStyle>
|
sl@0
|
208 |
class _Floating_limits : public _Numeric_limits_base<__number>
|
sl@0
|
209 |
{
|
sl@0
|
210 |
public:
|
sl@0
|
211 |
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_specialized, true);
|
sl@0
|
212 |
|
sl@0
|
213 |
BOOST_STL_DECLARE_LIMITS_MEMBER(int, digits, __Digits);
|
sl@0
|
214 |
BOOST_STL_DECLARE_LIMITS_MEMBER(int, digits10, __Digits10);
|
sl@0
|
215 |
|
sl@0
|
216 |
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_signed, true);
|
sl@0
|
217 |
|
sl@0
|
218 |
BOOST_STL_DECLARE_LIMITS_MEMBER(int, radix, 2);
|
sl@0
|
219 |
|
sl@0
|
220 |
BOOST_STL_DECLARE_LIMITS_MEMBER(int, min_exponent, __MinExp);
|
sl@0
|
221 |
BOOST_STL_DECLARE_LIMITS_MEMBER(int, max_exponent, __MaxExp);
|
sl@0
|
222 |
BOOST_STL_DECLARE_LIMITS_MEMBER(int, min_exponent10, __MinExp10);
|
sl@0
|
223 |
BOOST_STL_DECLARE_LIMITS_MEMBER(int, max_exponent10, __MaxExp10);
|
sl@0
|
224 |
|
sl@0
|
225 |
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, has_infinity, true);
|
sl@0
|
226 |
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, has_quiet_NaN, true);
|
sl@0
|
227 |
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, has_signaling_NaN, true);
|
sl@0
|
228 |
BOOST_STL_DECLARE_LIMITS_MEMBER(float_denorm_style,
|
sl@0
|
229 |
has_denorm,
|
sl@0
|
230 |
denorm_indeterminate);
|
sl@0
|
231 |
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, has_denorm_loss, false);
|
sl@0
|
232 |
|
sl@0
|
233 |
|
sl@0
|
234 |
static __number infinity() throw() {
|
sl@0
|
235 |
return float_helper<__number, __InfinityWord>::get_word();
|
sl@0
|
236 |
}
|
sl@0
|
237 |
static __number quiet_NaN() throw() {
|
sl@0
|
238 |
return float_helper<__number,__QNaNWord>::get_word();
|
sl@0
|
239 |
}
|
sl@0
|
240 |
static __number signaling_NaN() throw() {
|
sl@0
|
241 |
return float_helper<__number,__SNaNWord>::get_word();
|
sl@0
|
242 |
}
|
sl@0
|
243 |
|
sl@0
|
244 |
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_iec559, __IsIEC559);
|
sl@0
|
245 |
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_bounded, true);
|
sl@0
|
246 |
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, traps, false /* was: true */ );
|
sl@0
|
247 |
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, tinyness_before, false);
|
sl@0
|
248 |
|
sl@0
|
249 |
BOOST_STL_DECLARE_LIMITS_MEMBER(float_round_style, round_style, __RoundStyle);
|
sl@0
|
250 |
};
|
sl@0
|
251 |
|
sl@0
|
252 |
// Class numeric_limits
|
sl@0
|
253 |
|
sl@0
|
254 |
// The unspecialized class.
|
sl@0
|
255 |
|
sl@0
|
256 |
template<class T>
|
sl@0
|
257 |
class numeric_limits : public _Numeric_limits_base<T> {};
|
sl@0
|
258 |
|
sl@0
|
259 |
// Specializations for all built-in integral types.
|
sl@0
|
260 |
|
sl@0
|
261 |
template<>
|
sl@0
|
262 |
class numeric_limits<bool>
|
sl@0
|
263 |
: public _Integer_limits<bool, false, true, 0>
|
sl@0
|
264 |
{};
|
sl@0
|
265 |
|
sl@0
|
266 |
template<>
|
sl@0
|
267 |
class numeric_limits<char>
|
sl@0
|
268 |
: public _Integer_limits<char, CHAR_MIN, CHAR_MAX>
|
sl@0
|
269 |
{};
|
sl@0
|
270 |
|
sl@0
|
271 |
template<>
|
sl@0
|
272 |
class numeric_limits<signed char>
|
sl@0
|
273 |
: public _Integer_limits<signed char, SCHAR_MIN, SCHAR_MAX>
|
sl@0
|
274 |
{};
|
sl@0
|
275 |
|
sl@0
|
276 |
template<>
|
sl@0
|
277 |
class numeric_limits<unsigned char>
|
sl@0
|
278 |
: public _Integer_limits<unsigned char, 0, UCHAR_MAX>
|
sl@0
|
279 |
{};
|
sl@0
|
280 |
|
sl@0
|
281 |
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
|
sl@0
|
282 |
template<>
|
sl@0
|
283 |
class numeric_limits<wchar_t>
|
sl@0
|
284 |
#if !defined(WCHAR_MAX) || !defined(WCHAR_MIN)
|
sl@0
|
285 |
#if defined(_WIN32) || defined(__CYGWIN__)
|
sl@0
|
286 |
: public _Integer_limits<wchar_t, 0, USHRT_MAX>
|
sl@0
|
287 |
#elif defined(__hppa)
|
sl@0
|
288 |
// wchar_t has "unsigned int" as the underlying type
|
sl@0
|
289 |
: public _Integer_limits<wchar_t, 0, UINT_MAX>
|
sl@0
|
290 |
#else
|
sl@0
|
291 |
// assume that wchar_t has "int" as the underlying type
|
sl@0
|
292 |
: public _Integer_limits<wchar_t, INT_MIN, INT_MAX>
|
sl@0
|
293 |
#endif
|
sl@0
|
294 |
#else
|
sl@0
|
295 |
// we have WCHAR_MIN and WCHAR_MAX defined, so use it
|
sl@0
|
296 |
: public _Integer_limits<wchar_t, WCHAR_MIN, WCHAR_MAX>
|
sl@0
|
297 |
#endif
|
sl@0
|
298 |
{};
|
sl@0
|
299 |
#endif
|
sl@0
|
300 |
|
sl@0
|
301 |
template<>
|
sl@0
|
302 |
class numeric_limits<short>
|
sl@0
|
303 |
: public _Integer_limits<short, SHRT_MIN, SHRT_MAX>
|
sl@0
|
304 |
{};
|
sl@0
|
305 |
|
sl@0
|
306 |
template<>
|
sl@0
|
307 |
class numeric_limits<unsigned short>
|
sl@0
|
308 |
: public _Integer_limits<unsigned short, 0, USHRT_MAX>
|
sl@0
|
309 |
{};
|
sl@0
|
310 |
|
sl@0
|
311 |
template<>
|
sl@0
|
312 |
class numeric_limits<int>
|
sl@0
|
313 |
: public _Integer_limits<int, INT_MIN, INT_MAX>
|
sl@0
|
314 |
{};
|
sl@0
|
315 |
|
sl@0
|
316 |
template<>
|
sl@0
|
317 |
class numeric_limits<unsigned int>
|
sl@0
|
318 |
: public _Integer_limits<unsigned int, 0, UINT_MAX>
|
sl@0
|
319 |
{};
|
sl@0
|
320 |
|
sl@0
|
321 |
template<>
|
sl@0
|
322 |
class numeric_limits<long>
|
sl@0
|
323 |
: public _Integer_limits<long, LONG_MIN, LONG_MAX>
|
sl@0
|
324 |
{};
|
sl@0
|
325 |
|
sl@0
|
326 |
template<>
|
sl@0
|
327 |
class numeric_limits<unsigned long>
|
sl@0
|
328 |
: public _Integer_limits<unsigned long, 0, ULONG_MAX>
|
sl@0
|
329 |
{};
|
sl@0
|
330 |
|
sl@0
|
331 |
#ifdef __GNUC__
|
sl@0
|
332 |
|
sl@0
|
333 |
// Some compilers have long long, but don't define the
|
sl@0
|
334 |
// LONGLONG_MIN and LONGLONG_MAX macros in limits.h. This
|
sl@0
|
335 |
// assumes that long long is 64 bits.
|
sl@0
|
336 |
#if !defined(LONGLONG_MAX) && !defined(ULONGLONG_MAX)
|
sl@0
|
337 |
|
sl@0
|
338 |
# define ULONGLONG_MAX 0xffffffffffffffffLLU
|
sl@0
|
339 |
# define LONGLONG_MAX 0x7fffffffffffffffLL
|
sl@0
|
340 |
|
sl@0
|
341 |
#endif
|
sl@0
|
342 |
|
sl@0
|
343 |
#if !defined(LONGLONG_MIN)
|
sl@0
|
344 |
# define LONGLONG_MIN (-LONGLONG_MAX - 1)
|
sl@0
|
345 |
#endif
|
sl@0
|
346 |
|
sl@0
|
347 |
|
sl@0
|
348 |
#if !defined(ULONGLONG_MIN)
|
sl@0
|
349 |
# define ULONGLONG_MIN 0
|
sl@0
|
350 |
#endif
|
sl@0
|
351 |
|
sl@0
|
352 |
#endif /* __GNUC__ */
|
sl@0
|
353 |
|
sl@0
|
354 |
// Specializations for all built-in floating-point type.
|
sl@0
|
355 |
|
sl@0
|
356 |
template<> class numeric_limits<float>
|
sl@0
|
357 |
: public _Floating_limits<float,
|
sl@0
|
358 |
FLT_MANT_DIG, // Binary digits of precision
|
sl@0
|
359 |
FLT_DIG, // Decimal digits of precision
|
sl@0
|
360 |
FLT_MIN_EXP, // Minimum exponent
|
sl@0
|
361 |
FLT_MAX_EXP, // Maximum exponent
|
sl@0
|
362 |
FLT_MIN_10_EXP, // Minimum base 10 exponent
|
sl@0
|
363 |
FLT_MAX_10_EXP, // Maximum base 10 exponent
|
sl@0
|
364 |
#if defined(BOOST_BIG_ENDIAN)
|
sl@0
|
365 |
0x7f80 << (sizeof(int)*CHAR_BIT-16), // Last word of +infinity
|
sl@0
|
366 |
0x7f81 << (sizeof(int)*CHAR_BIT-16), // Last word of quiet NaN
|
sl@0
|
367 |
0x7fc1 << (sizeof(int)*CHAR_BIT-16), // Last word of signaling NaN
|
sl@0
|
368 |
#else
|
sl@0
|
369 |
0x7f800000u, // Last word of +infinity
|
sl@0
|
370 |
0x7f810000u, // Last word of quiet NaN
|
sl@0
|
371 |
0x7fc10000u, // Last word of signaling NaN
|
sl@0
|
372 |
#endif
|
sl@0
|
373 |
true, // conforms to iec559
|
sl@0
|
374 |
round_to_nearest>
|
sl@0
|
375 |
{
|
sl@0
|
376 |
public:
|
sl@0
|
377 |
static float min BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return FLT_MIN; }
|
sl@0
|
378 |
static float denorm_min() throw() { return FLT_MIN; }
|
sl@0
|
379 |
static float max BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return FLT_MAX; }
|
sl@0
|
380 |
static float epsilon() throw() { return FLT_EPSILON; }
|
sl@0
|
381 |
static float round_error() throw() { return 0.5f; } // Units: ulps.
|
sl@0
|
382 |
};
|
sl@0
|
383 |
|
sl@0
|
384 |
template<> class numeric_limits<double>
|
sl@0
|
385 |
: public _Floating_limits<double,
|
sl@0
|
386 |
DBL_MANT_DIG, // Binary digits of precision
|
sl@0
|
387 |
DBL_DIG, // Decimal digits of precision
|
sl@0
|
388 |
DBL_MIN_EXP, // Minimum exponent
|
sl@0
|
389 |
DBL_MAX_EXP, // Maximum exponent
|
sl@0
|
390 |
DBL_MIN_10_EXP, // Minimum base 10 exponent
|
sl@0
|
391 |
DBL_MAX_10_EXP, // Maximum base 10 exponent
|
sl@0
|
392 |
#if defined(BOOST_BIG_ENDIAN)
|
sl@0
|
393 |
0x7ff0 << (sizeof(int)*CHAR_BIT-16), // Last word of +infinity
|
sl@0
|
394 |
0x7ff1 << (sizeof(int)*CHAR_BIT-16), // Last word of quiet NaN
|
sl@0
|
395 |
0x7ff9 << (sizeof(int)*CHAR_BIT-16), // Last word of signaling NaN
|
sl@0
|
396 |
#else
|
sl@0
|
397 |
0x7ff00000u, // Last word of +infinity
|
sl@0
|
398 |
0x7ff10000u, // Last word of quiet NaN
|
sl@0
|
399 |
0x7ff90000u, // Last word of signaling NaN
|
sl@0
|
400 |
#endif
|
sl@0
|
401 |
true, // conforms to iec559
|
sl@0
|
402 |
round_to_nearest>
|
sl@0
|
403 |
{
|
sl@0
|
404 |
public:
|
sl@0
|
405 |
static double min BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return DBL_MIN; }
|
sl@0
|
406 |
static double denorm_min() throw() { return DBL_MIN; }
|
sl@0
|
407 |
static double max BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return DBL_MAX; }
|
sl@0
|
408 |
static double epsilon() throw() { return DBL_EPSILON; }
|
sl@0
|
409 |
static double round_error() throw() { return 0.5; } // Units: ulps.
|
sl@0
|
410 |
};
|
sl@0
|
411 |
|
sl@0
|
412 |
template<> class numeric_limits<long double>
|
sl@0
|
413 |
: public _Floating_limits<long double,
|
sl@0
|
414 |
LDBL_MANT_DIG, // Binary digits of precision
|
sl@0
|
415 |
LDBL_DIG, // Decimal digits of precision
|
sl@0
|
416 |
LDBL_MIN_EXP, // Minimum exponent
|
sl@0
|
417 |
LDBL_MAX_EXP, // Maximum exponent
|
sl@0
|
418 |
LDBL_MIN_10_EXP,// Minimum base 10 exponent
|
sl@0
|
419 |
LDBL_MAX_10_EXP,// Maximum base 10 exponent
|
sl@0
|
420 |
#if defined(BOOST_BIG_ENDIAN)
|
sl@0
|
421 |
0x7ff0 << (sizeof(int)*CHAR_BIT-16), // Last word of +infinity
|
sl@0
|
422 |
0x7ff1 << (sizeof(int)*CHAR_BIT-16), // Last word of quiet NaN
|
sl@0
|
423 |
0x7ff9 << (sizeof(int)*CHAR_BIT-16), // Last word of signaling NaN
|
sl@0
|
424 |
#else
|
sl@0
|
425 |
0x7fff8000u, // Last word of +infinity
|
sl@0
|
426 |
0x7fffc000u, // Last word of quiet NaN
|
sl@0
|
427 |
0x7fff9000u, // Last word of signaling NaN
|
sl@0
|
428 |
#endif
|
sl@0
|
429 |
false, // Doesn't conform to iec559
|
sl@0
|
430 |
round_to_nearest>
|
sl@0
|
431 |
{
|
sl@0
|
432 |
public:
|
sl@0
|
433 |
static long double min BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return LDBL_MIN; }
|
sl@0
|
434 |
static long double denorm_min() throw() { return LDBL_MIN; }
|
sl@0
|
435 |
static long double max BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return LDBL_MAX; }
|
sl@0
|
436 |
static long double epsilon() throw() { return LDBL_EPSILON; }
|
sl@0
|
437 |
static long double round_error() throw() { return 4; } // Units: ulps.
|
sl@0
|
438 |
};
|
sl@0
|
439 |
|
sl@0
|
440 |
} // namespace std
|
sl@0
|
441 |
|
sl@0
|
442 |
#endif /* BOOST_SGI_CPP_LIMITS */
|
sl@0
|
443 |
|
sl@0
|
444 |
// Local Variables:
|
sl@0
|
445 |
// mode:C++
|
sl@0
|
446 |
// End:
|
sl@0
|
447 |
|
sl@0
|
448 |
|
sl@0
|
449 |
|