📄 limits.hpp
字号:
BOOST_STL_DECLARE_LIMITS_MEMBER(float_denorm_style, has_denorm, denorm_indeterminate); BOOST_STL_DECLARE_LIMITS_MEMBER(bool, has_denorm_loss, false); 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.template<class T> 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_Ttemplate<>class numeric_limits<wchar_t>#if !defined(WCHAR_MAX) || !defined(WCHAR_MIN)#if defined(_WIN32) || defined(__CYGWIN__) : public _Integer_limits<wchar_t, 0, USHRT_MAX>#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>#endif#else// we have WCHAR_MIN and WCHAR_MAX defined, so use it : public _Integer_limits<wchar_t, WCHAR_MIN, WCHAR_MAX>#endif{};#endiftemplate<>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.#if !defined(LONGLONG_MAX) && !defined(ULONGLONG_MAX)# define ULONGLONG_MAX 0xffffffffffffffffLLU# define LONGLONG_MAX 0x7fffffffffffffffLL#endif#if !defined(LONGLONG_MIN)# define LONGLONG_MIN (-LONGLONG_MAX - 1)#endif #if !defined(ULONGLONG_MIN)# define ULONGLONG_MIN 0#endif #endif /* __GNUC__ */// Specializations for all built-in floating-point type.template<> class numeric_limits<float> : 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#if defined(BOOST_BIG_ENDIAN) 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#else 0x7f800000u, // Last word of +infinity 0x7f810000u, // Last word of quiet NaN 0x7fc10000u, // Last word of signaling NaN#endif true, // conforms to iec559 round_to_nearest>{public: static float min BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return FLT_MIN; } static float denorm_min() throw() { return FLT_MIN; } static float max BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return FLT_MAX; } static float epsilon() throw() { return FLT_EPSILON; } static float round_error() throw() { return 0.5f; } // Units: ulps.};template<> class numeric_limits<double> : 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#if defined(BOOST_BIG_ENDIAN) 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#else 0x7ff00000u, // Last word of +infinity 0x7ff10000u, // Last word of quiet NaN 0x7ff90000u, // Last word of signaling NaN#endif true, // conforms to iec559 round_to_nearest>{public: static double min BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return DBL_MIN; } static double denorm_min() throw() { return DBL_MIN; } static double max BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return DBL_MAX; } static double epsilon() throw() { return DBL_EPSILON; } static double round_error() throw() { return 0.5; } // Units: ulps.};template<> class numeric_limits<long double> : 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#if defined(BOOST_BIG_ENDIAN) 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#else 0x7fff8000u, // Last word of +infinity 0x7fffc000u, // Last word of quiet NaN 0x7fff9000u, // Last word of signaling NaN#endif false, // Doesn't conform to iec559 round_to_nearest>{public: static long double min BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return LDBL_MIN; } static long double denorm_min() throw() { return LDBL_MIN; } static long double max BOOST_PREVENT_MACRO_SUBSTITUTION () throw() { return LDBL_MAX; } 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:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -