2006-12-11 14:31:35 +00:00
|
|
|
// Copyright 2001 John Maddock
|
|
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompany-
|
|
|
|
// ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
|
2001-06-01 11:56:18 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1997
|
|
|
|
* Silicon Graphics Computer Systems, Inc.
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, distribute and sell this software
|
|
|
|
* and its documentation for any purpose is hereby granted without fee,
|
|
|
|
* provided that the above copyright notice appear in all copies and
|
|
|
|
* that both that copyright notice and this permission notice appear
|
|
|
|
* in supporting documentation. Silicon Graphics makes no
|
|
|
|
* representations about the suitability of this software for any
|
|
|
|
* purpose. It is provided "as is" without express or implied warranty.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* NOTE: This is not portable code. Parts of numeric_limits<> are
|
|
|
|
* inherently machine-dependent, and this file is written for the MIPS
|
|
|
|
* architecture and the SGI MIPSpro C++ compiler. Parts of it (in
|
|
|
|
* particular, some of the characteristics of floating-point types)
|
|
|
|
* are almost certainly incorrect for any other platform.
|
|
|
|
*/
|
|
|
|
|
2002-05-21 23:39:58 +00:00
|
|
|
/* The above comment is almost certainly out of date. This file works
|
|
|
|
* on systems other than SGI MIPSpro C++ now.
|
|
|
|
*/
|
|
|
|
|
2001-06-01 11:56:18 +00:00
|
|
|
/*
|
|
|
|
* Revision history:
|
2002-05-21 23:39:58 +00:00
|
|
|
* 21 Sep 2001:
|
|
|
|
* Only include <cwchar> if BOOST_NO_CWCHAR is defined. (Darin Adler)
|
2001-08-29 22:33:34 +00:00
|
|
|
* 10 Aug 2001:
|
|
|
|
* Added MIPS (big endian) to the big endian family. (Jens Maurer)
|
2001-06-01 11:56:18 +00:00
|
|
|
* 13 Apr 2001:
|
|
|
|
* Added powerpc to the big endian family. (Jeremy Siek)
|
|
|
|
* 5 Apr 2001:
|
|
|
|
* Added sparc (big endian) processor support (John Maddock).
|
|
|
|
* Initial sub:
|
2002-05-21 23:39:58 +00:00
|
|
|
* Modified by Jens Maurer for gcc 2.95 on x86.
|
2001-06-01 11:56:18 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef BOOST_SGI_CPP_LIMITS
|
|
|
|
#define BOOST_SGI_CPP_LIMITS
|
|
|
|
|
|
|
|
#include <climits>
|
|
|
|
#include <cfloat>
|
|
|
|
#include <boost/config.hpp>
|
2006-03-05 18:22:35 +00:00
|
|
|
#include <boost/detail/endian.hpp>
|
2001-06-01 11:56:18 +00:00
|
|
|
|
2002-05-21 23:39:58 +00:00
|
|
|
#ifndef BOOST_NO_CWCHAR
|
|
|
|
#include <cwchar> // for WCHAR_MIN and WCHAR_MAX
|
|
|
|
#endif
|
|
|
|
|
2001-06-01 11:56:18 +00:00
|
|
|
namespace std {
|
|
|
|
|
|
|
|
enum float_round_style {
|
|
|
|
round_indeterminate = -1,
|
|
|
|
round_toward_zero = 0,
|
|
|
|
round_to_nearest = 1,
|
|
|
|
round_toward_infinity = 2,
|
|
|
|
round_toward_neg_infinity = 3
|
|
|
|
};
|
|
|
|
|
|
|
|
enum float_denorm_style {
|
|
|
|
denorm_indeterminate = -1,
|
|
|
|
denorm_absent = 0,
|
|
|
|
denorm_present = 1
|
|
|
|
};
|
|
|
|
|
|
|
|
// The C++ standard (section 18.2.1) requires that some of the members of
|
|
|
|
// numeric_limits be static const data members that are given constant-
|
|
|
|
// initializers within the class declaration. On compilers where the
|
|
|
|
// BOOST_NO_INCLASS_MEMBER_INITIALIZATION macro is defined, it is impossible to write
|
|
|
|
// a standard-conforming numeric_limits class.
|
|
|
|
//
|
|
|
|
// There are two possible workarounds: either initialize the data
|
|
|
|
// members outside the class, or change them from data members to
|
|
|
|
// enums. Neither workaround is satisfactory: the former makes it
|
|
|
|
// impossible to use the data members in constant-expressions, and the
|
|
|
|
// latter means they have the wrong type and that it is impossible to
|
|
|
|
// take their addresses. We choose the former workaround.
|
|
|
|
|
|
|
|
#ifdef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
|
|
|
|
# define BOOST_STL_DECLARE_LIMITS_MEMBER(__mem_type, __mem_name, __mem_value) \
|
|
|
|
enum { __mem_name = __mem_value }
|
|
|
|
#else /* BOOST_NO_INCLASS_MEMBER_INITIALIZATION */
|
|
|
|
# define BOOST_STL_DECLARE_LIMITS_MEMBER(__mem_type, __mem_name, __mem_value) \
|
|
|
|
static const __mem_type __mem_name = __mem_value
|
|
|
|
#endif /* BOOST_NO_INCLASS_MEMBER_INITIALIZATION */
|
|
|
|
|
2002-05-21 23:39:58 +00:00
|
|
|
// Base class for all specializations of numeric_limits.
|
2001-06-01 11:56:18 +00:00
|
|
|
template <class __number>
|
|
|
|
class _Numeric_limits_base {
|
|
|
|
public:
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_specialized, false);
|
|
|
|
|
2004-11-20 09:08:45 +00:00
|
|
|
static __number min BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return __number(); }
|
|
|
|
static __number max BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return __number(); }
|
2001-06-01 11:56:18 +00:00
|
|
|
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(int, digits, 0);
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(int, digits10, 0);
|
|
|
|
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_signed, false);
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_integer, false);
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_exact, false);
|
|
|
|
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(int, radix, 0);
|
|
|
|
|
|
|
|
static __number epsilon() throw() { return __number(); }
|
|
|
|
static __number round_error() throw() { return __number(); }
|
|
|
|
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(int, min_exponent, 0);
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(int, min_exponent10, 0);
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(int, max_exponent, 0);
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(int, max_exponent10, 0);
|
|
|
|
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, has_infinity, false);
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, has_quiet_NaN, false);
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, has_signaling_NaN, false);
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(float_denorm_style,
|
2002-07-28 23:38:39 +00:00
|
|
|
has_denorm,
|
|
|
|
denorm_absent);
|
2001-06-01 11:56:18 +00:00
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, has_denorm_loss, false);
|
|
|
|
|
|
|
|
static __number infinity() throw() { return __number(); }
|
|
|
|
static __number quiet_NaN() throw() { return __number(); }
|
|
|
|
static __number signaling_NaN() throw() { return __number(); }
|
|
|
|
static __number denorm_min() throw() { return __number(); }
|
|
|
|
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_iec559, false);
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_bounded, false);
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_modulo, false);
|
|
|
|
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, traps, false);
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, tinyness_before, false);
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(float_round_style,
|
2002-07-28 23:38:39 +00:00
|
|
|
round_style,
|
|
|
|
round_toward_zero);
|
2001-06-01 11:56:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Base class for integers.
|
|
|
|
|
|
|
|
template <class _Int,
|
2002-07-28 23:38:39 +00:00
|
|
|
_Int __imin,
|
|
|
|
_Int __imax,
|
|
|
|
int __idigits = -1>
|
|
|
|
class _Integer_limits : public _Numeric_limits_base<_Int>
|
2001-06-01 11:56:18 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_specialized, true);
|
|
|
|
|
2004-11-20 09:08:45 +00:00
|
|
|
static _Int min BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return __imin; }
|
|
|
|
static _Int max BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return __imax; }
|
2001-06-01 11:56:18 +00:00
|
|
|
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(int,
|
2002-07-28 23:38:39 +00:00
|
|
|
digits,
|
|
|
|
(__idigits < 0) ? (int)(sizeof(_Int) * CHAR_BIT)
|
|
|
|
- (__imin == 0 ? 0 : 1)
|
|
|
|
: __idigits);
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(int, digits10, (digits * 301) / 1000);
|
|
|
|
// log 2 = 0.301029995664...
|
2001-06-01 11:56:18 +00:00
|
|
|
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_signed, __imin != 0);
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_integer, true);
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_exact, true);
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(int, radix, 2);
|
|
|
|
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_bounded, true);
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_modulo, true);
|
|
|
|
};
|
|
|
|
|
|
|
|
#if defined(BOOST_BIG_ENDIAN)
|
|
|
|
|
|
|
|
template<class Number, unsigned int Word>
|
|
|
|
struct float_helper{
|
|
|
|
static Number get_word() throw() {
|
|
|
|
// sizeof(long double) == 16
|
|
|
|
const unsigned int _S_word[4] = { Word, 0, 0, 0 };
|
|
|
|
return *reinterpret_cast<const Number*>(&_S_word);
|
2002-07-28 23:38:39 +00:00
|
|
|
}
|
2001-06-01 11:56:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
template<class Number, unsigned int Word>
|
|
|
|
struct float_helper{
|
|
|
|
static Number get_word() throw() {
|
|
|
|
// sizeof(long double) == 12, but only 10 bytes significant
|
|
|
|
const unsigned int _S_word[4] = { 0, 0, 0, Word };
|
|
|
|
return *reinterpret_cast<const Number*>(
|
2002-07-28 23:38:39 +00:00
|
|
|
reinterpret_cast<const char *>(&_S_word)+16-
|
|
|
|
(sizeof(Number) == 12 ? 10 : sizeof(Number)));
|
|
|
|
}
|
2001-06-01 11:56:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Base class for floating-point numbers.
|
|
|
|
template <class __number,
|
2002-07-28 23:38:39 +00:00
|
|
|
int __Digits, int __Digits10,
|
|
|
|
int __MinExp, int __MaxExp,
|
|
|
|
int __MinExp10, int __MaxExp10,
|
|
|
|
unsigned int __InfinityWord,
|
|
|
|
unsigned int __QNaNWord, unsigned int __SNaNWord,
|
|
|
|
bool __IsIEC559,
|
|
|
|
float_round_style __RoundStyle>
|
2001-06-01 11:56:18 +00:00
|
|
|
class _Floating_limits : public _Numeric_limits_base<__number>
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_specialized, true);
|
|
|
|
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(int, digits, __Digits);
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(int, digits10, __Digits10);
|
|
|
|
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_signed, true);
|
|
|
|
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(int, radix, 2);
|
|
|
|
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(int, min_exponent, __MinExp);
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(int, max_exponent, __MaxExp);
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(int, min_exponent10, __MinExp10);
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(int, max_exponent10, __MaxExp10);
|
|
|
|
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, has_infinity, true);
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, has_quiet_NaN, true);
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, has_signaling_NaN, true);
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(float_denorm_style,
|
2002-07-28 23:38:39 +00:00
|
|
|
has_denorm,
|
|
|
|
denorm_indeterminate);
|
2001-06-01 11:56:18 +00:00
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, has_denorm_loss, false);
|
|
|
|
|
2002-07-28 23:38:39 +00:00
|
|
|
|
2001-06-01 11:56:18 +00:00
|
|
|
static __number infinity() throw() {
|
|
|
|
return float_helper<__number, __InfinityWord>::get_word();
|
|
|
|
}
|
|
|
|
static __number quiet_NaN() throw() {
|
|
|
|
return float_helper<__number,__QNaNWord>::get_word();
|
|
|
|
}
|
|
|
|
static __number signaling_NaN() throw() {
|
|
|
|
return float_helper<__number,__SNaNWord>::get_word();
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_iec559, __IsIEC559);
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, is_bounded, true);
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, traps, false /* was: true */ );
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(bool, tinyness_before, false);
|
|
|
|
|
|
|
|
BOOST_STL_DECLARE_LIMITS_MEMBER(float_round_style, round_style, __RoundStyle);
|
|
|
|
};
|
|
|
|
|
|
|
|
// Class numeric_limits
|
|
|
|
|
|
|
|
// The unspecialized class.
|
|
|
|
|
2002-07-28 23:38:39 +00:00
|
|
|
template<class T>
|
2001-06-01 11:56:18 +00:00
|
|
|
class numeric_limits : public _Numeric_limits_base<T> {};
|
|
|
|
|
|
|
|
// Specializations for all built-in integral types.
|
|
|
|
|
|
|
|
template<>
|
|
|
|
class numeric_limits<bool>
|
|
|
|
: public _Integer_limits<bool, false, true, 0>
|
|
|
|
{};
|
|
|
|
|
|
|
|
template<>
|
|
|
|
class numeric_limits<char>
|
|
|
|
: public _Integer_limits<char, CHAR_MIN, CHAR_MAX>
|
|
|
|
{};
|
|
|
|
|
|
|
|
template<>
|
|
|
|
class numeric_limits<signed char>
|
|
|
|
: public _Integer_limits<signed char, SCHAR_MIN, SCHAR_MAX>
|
|
|
|
{};
|
|
|
|
|
|
|
|
template<>
|
|
|
|
class numeric_limits<unsigned char>
|
|
|
|
: public _Integer_limits<unsigned char, 0, UCHAR_MAX>
|
|
|
|
{};
|
|
|
|
|
|
|
|
#ifndef BOOST_NO_INTRINSIC_WCHAR_T
|
|
|
|
template<>
|
|
|
|
class numeric_limits<wchar_t>
|
2002-05-21 23:39:58 +00:00
|
|
|
#if !defined(WCHAR_MAX) || !defined(WCHAR_MIN)
|
|
|
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
2001-06-01 11:56:18 +00:00
|
|
|
: public _Integer_limits<wchar_t, 0, USHRT_MAX>
|
2002-05-21 23:39:58 +00:00
|
|
|
#elif defined(__hppa)
|
|
|
|
// wchar_t has "unsigned int" as the underlying type
|
|
|
|
: public _Integer_limits<wchar_t, 0, UINT_MAX>
|
|
|
|
#else
|
|
|
|
// assume that wchar_t has "int" as the underlying type
|
|
|
|
: public _Integer_limits<wchar_t, INT_MIN, INT_MAX>
|
2001-06-01 11:56:18 +00:00
|
|
|
#endif
|
|
|
|
#else
|
2002-05-21 23:39:58 +00:00
|
|
|
// we have WCHAR_MIN and WCHAR_MAX defined, so use it
|
2001-06-01 11:56:18 +00:00
|
|
|
: public _Integer_limits<wchar_t, WCHAR_MIN, WCHAR_MAX>
|
|
|
|
#endif
|
2002-05-21 23:39:58 +00:00
|
|
|
{};
|
2001-06-01 11:56:18 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
template<>
|
|
|
|
class numeric_limits<short>
|
|
|
|
: public _Integer_limits<short, SHRT_MIN, SHRT_MAX>
|
|
|
|
{};
|
|
|
|
|
|
|
|
template<>
|
|
|
|
class numeric_limits<unsigned short>
|
|
|
|
: public _Integer_limits<unsigned short, 0, USHRT_MAX>
|
|
|
|
{};
|
|
|
|
|
|
|
|
template<>
|
|
|
|
class numeric_limits<int>
|
|
|
|
: public _Integer_limits<int, INT_MIN, INT_MAX>
|
|
|
|
{};
|
|
|
|
|
|
|
|
template<>
|
|
|
|
class numeric_limits<unsigned int>
|
|
|
|
: public _Integer_limits<unsigned int, 0, UINT_MAX>
|
|
|
|
{};
|
|
|
|
|
|
|
|
template<>
|
|
|
|
class numeric_limits<long>
|
|
|
|
: public _Integer_limits<long, LONG_MIN, LONG_MAX>
|
|
|
|
{};
|
|
|
|
|
|
|
|
template<>
|
|
|
|
class numeric_limits<unsigned long>
|
|
|
|
: public _Integer_limits<unsigned long, 0, ULONG_MAX>
|
|
|
|
{};
|
|
|
|
|
|
|
|
#ifdef __GNUC__
|
|
|
|
|
|
|
|
// Some compilers have long long, but don't define the
|
|
|
|
// LONGLONG_MIN and LONGLONG_MAX macros in limits.h. This
|
|
|
|
// assumes that long long is 64 bits.
|
2002-05-21 23:39:58 +00:00
|
|
|
#if !defined(LONGLONG_MAX) && !defined(ULONGLONG_MAX)
|
2001-06-01 11:56:18 +00:00
|
|
|
|
2002-05-21 23:39:58 +00:00
|
|
|
# define ULONGLONG_MAX 0xffffffffffffffffLLU
|
|
|
|
# define LONGLONG_MAX 0x7fffffffffffffffLL
|
2001-06-01 11:56:18 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2002-05-21 23:39:58 +00:00
|
|
|
#if !defined(LONGLONG_MIN)
|
|
|
|
# define LONGLONG_MIN (-LONGLONG_MAX - 1)
|
2002-07-28 23:38:39 +00:00
|
|
|
#endif
|
2002-05-21 23:39:58 +00:00
|
|
|
|
2001-06-01 11:56:18 +00:00
|
|
|
|
2002-07-28 23:38:39 +00:00
|
|
|
#if !defined(ULONGLONG_MIN)
|
|
|
|
# define ULONGLONG_MIN 0
|
|
|
|
#endif
|
2001-06-01 11:56:18 +00:00
|
|
|
|
|
|
|
#endif /* __GNUC__ */
|
|
|
|
|
|
|
|
// Specializations for all built-in floating-point type.
|
|
|
|
|
|
|
|
template<> class numeric_limits<float>
|
2002-07-28 23:38:39 +00:00
|
|
|
: public _Floating_limits<float,
|
|
|
|
FLT_MANT_DIG, // Binary digits of precision
|
|
|
|
FLT_DIG, // Decimal digits of precision
|
|
|
|
FLT_MIN_EXP, // Minimum exponent
|
|
|
|
FLT_MAX_EXP, // Maximum exponent
|
|
|
|
FLT_MIN_10_EXP, // Minimum base 10 exponent
|
|
|
|
FLT_MAX_10_EXP, // Maximum base 10 exponent
|
2001-06-01 11:56:18 +00:00
|
|
|
#if defined(BOOST_BIG_ENDIAN)
|
2002-07-28 23:38:39 +00:00
|
|
|
0x7f80 << (sizeof(int)*CHAR_BIT-16), // Last word of +infinity
|
|
|
|
0x7f81 << (sizeof(int)*CHAR_BIT-16), // Last word of quiet NaN
|
|
|
|
0x7fc1 << (sizeof(int)*CHAR_BIT-16), // Last word of signaling NaN
|
2001-06-01 11:56:18 +00:00
|
|
|
#else
|
2002-07-28 23:38:39 +00:00
|
|
|
0x7f800000u, // Last word of +infinity
|
|
|
|
0x7f810000u, // Last word of quiet NaN
|
|
|
|
0x7fc10000u, // Last word of signaling NaN
|
2001-06-01 11:56:18 +00:00
|
|
|
#endif
|
2002-07-28 23:38:39 +00:00
|
|
|
true, // conforms to iec559
|
|
|
|
round_to_nearest>
|
2001-06-01 11:56:18 +00:00
|
|
|
{
|
|
|
|
public:
|
2004-11-20 09:08:45 +00:00
|
|
|
static float min BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return FLT_MIN; }
|
2001-06-01 11:56:18 +00:00
|
|
|
static float denorm_min() throw() { return FLT_MIN; }
|
2004-11-20 09:08:45 +00:00
|
|
|
static float max BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return FLT_MAX; }
|
2001-06-01 11:56:18 +00:00
|
|
|
static float epsilon() throw() { return FLT_EPSILON; }
|
|
|
|
static float round_error() throw() { return 0.5f; } // Units: ulps.
|
|
|
|
};
|
|
|
|
|
|
|
|
template<> class numeric_limits<double>
|
2002-07-28 23:38:39 +00:00
|
|
|
: public _Floating_limits<double,
|
|
|
|
DBL_MANT_DIG, // Binary digits of precision
|
|
|
|
DBL_DIG, // Decimal digits of precision
|
|
|
|
DBL_MIN_EXP, // Minimum exponent
|
|
|
|
DBL_MAX_EXP, // Maximum exponent
|
|
|
|
DBL_MIN_10_EXP, // Minimum base 10 exponent
|
|
|
|
DBL_MAX_10_EXP, // Maximum base 10 exponent
|
2001-06-01 11:56:18 +00:00
|
|
|
#if defined(BOOST_BIG_ENDIAN)
|
2002-07-28 23:38:39 +00:00
|
|
|
0x7ff0 << (sizeof(int)*CHAR_BIT-16), // Last word of +infinity
|
|
|
|
0x7ff1 << (sizeof(int)*CHAR_BIT-16), // Last word of quiet NaN
|
|
|
|
0x7ff9 << (sizeof(int)*CHAR_BIT-16), // Last word of signaling NaN
|
2001-06-01 11:56:18 +00:00
|
|
|
#else
|
2002-07-28 23:38:39 +00:00
|
|
|
0x7ff00000u, // Last word of +infinity
|
|
|
|
0x7ff10000u, // Last word of quiet NaN
|
|
|
|
0x7ff90000u, // Last word of signaling NaN
|
2001-06-01 11:56:18 +00:00
|
|
|
#endif
|
2002-07-28 23:38:39 +00:00
|
|
|
true, // conforms to iec559
|
|
|
|
round_to_nearest>
|
2001-06-01 11:56:18 +00:00
|
|
|
{
|
|
|
|
public:
|
2004-11-20 09:08:45 +00:00
|
|
|
static double min BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return DBL_MIN; }
|
2001-06-01 11:56:18 +00:00
|
|
|
static double denorm_min() throw() { return DBL_MIN; }
|
2004-11-20 09:08:45 +00:00
|
|
|
static double max BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return DBL_MAX; }
|
2001-06-01 11:56:18 +00:00
|
|
|
static double epsilon() throw() { return DBL_EPSILON; }
|
|
|
|
static double round_error() throw() { return 0.5; } // Units: ulps.
|
|
|
|
};
|
|
|
|
|
|
|
|
template<> class numeric_limits<long double>
|
2002-07-28 23:38:39 +00:00
|
|
|
: public _Floating_limits<long double,
|
|
|
|
LDBL_MANT_DIG, // Binary digits of precision
|
|
|
|
LDBL_DIG, // Decimal digits of precision
|
|
|
|
LDBL_MIN_EXP, // Minimum exponent
|
|
|
|
LDBL_MAX_EXP, // Maximum exponent
|
|
|
|
LDBL_MIN_10_EXP,// Minimum base 10 exponent
|
|
|
|
LDBL_MAX_10_EXP,// Maximum base 10 exponent
|
2001-06-01 11:56:18 +00:00
|
|
|
#if defined(BOOST_BIG_ENDIAN)
|
2002-07-28 23:38:39 +00:00
|
|
|
0x7ff0 << (sizeof(int)*CHAR_BIT-16), // Last word of +infinity
|
|
|
|
0x7ff1 << (sizeof(int)*CHAR_BIT-16), // Last word of quiet NaN
|
|
|
|
0x7ff9 << (sizeof(int)*CHAR_BIT-16), // Last word of signaling NaN
|
2001-06-01 11:56:18 +00:00
|
|
|
#else
|
2002-07-28 23:38:39 +00:00
|
|
|
0x7fff8000u, // Last word of +infinity
|
|
|
|
0x7fffc000u, // Last word of quiet NaN
|
|
|
|
0x7fff9000u, // Last word of signaling NaN
|
2001-06-01 11:56:18 +00:00
|
|
|
#endif
|
2002-07-28 23:38:39 +00:00
|
|
|
false, // Doesn't conform to iec559
|
|
|
|
round_to_nearest>
|
2001-06-01 11:56:18 +00:00
|
|
|
{
|
|
|
|
public:
|
2004-11-20 09:08:45 +00:00
|
|
|
static long double min BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return LDBL_MIN; }
|
2001-06-01 11:56:18 +00:00
|
|
|
static long double denorm_min() throw() { return LDBL_MIN; }
|
2004-11-20 09:08:45 +00:00
|
|
|
static long double max BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return LDBL_MAX; }
|
2001-06-01 11:56:18 +00:00
|
|
|
static long double epsilon() throw() { return LDBL_EPSILON; }
|
|
|
|
static long double round_error() throw() { return 4; } // Units: ulps.
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace std
|
|
|
|
|
|
|
|
#endif /* BOOST_SGI_CPP_LIMITS */
|
|
|
|
|
|
|
|
// Local Variables:
|
|
|
|
// mode:C++
|
|
|
|
// End:
|
2002-07-28 23:38:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
|