_limits.h

来自「stl的源码」· C头文件 代码 · 共 520 行 · 第 1/2 页

H
520
字号
#    define LONGLONG_MIN     (-LONGLONG_MAX-1i64)#    define ULONGLONG_MAX    0xffffffffffffffffUi64#  else#    ifndef LONGLONG_MAX#      define LONGLONG_MAX   0x7fffffffffffffffLL#    endif#    ifndef LONGLONG_MIN#      define LONGLONG_MIN   (-LONGLONG_MAX-1LL)#    endif#    ifndef ULONGLONG_MAX#      define ULONGLONG_MAX  0xffffffffffffffffULL#    endif#  endif#  if !defined (__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ <= 96) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 3)_STLP_TEMPLATE_NULLclass numeric_limits<_STLP_LONG_LONG>  : public _STLP_PRIV _Integer_limits<_STLP_LONG_LONG, LONGLONG_MIN, LONGLONG_MAX, -1, true>{};_STLP_TEMPLATE_NULLclass numeric_limits<unsigned _STLP_LONG_LONG>  : public _STLP_PRIV _Integer_limits<unsigned _STLP_LONG_LONG, 0, ULONGLONG_MAX, -1, true>{};#  else /* gcc 2.97 (after 2000-11-01), 2.98, 3.0 *//* newest gcc has new mangling scheme, that has problem with generating name [instantiated] of template specialization like _Integer_limits<_STLP_LONG_LONG, LONGLONG_MIN, LONGLONG_MAX, -1, true>                                  ~~~~~~~~~~~~  ~~~~~~~~~~~~ Below is code that solve this problem.   - ptr */_STLP_TEMPLATE_NULLclass numeric_limits<_STLP_LONG_LONG>  : public _STLP_PRIV _Numeric_limits_base<_STLP_LONG_LONG> {public:  static _STLP_LONG_LONG (_STLP_CALL min) () _STLP_NOTHROW { return LONGLONG_MIN; }  static _STLP_LONG_LONG (_STLP_CALL max) () _STLP_NOTHROW { return LONGLONG_MAX; }  _STLP_STATIC_CONSTANT(int, digits = ((int)((sizeof(_STLP_LONG_LONG) * (CHAR_BIT))) - 1));  _STLP_STATIC_CONSTANT(int, digits10 = (digits * 301UL) / 1000);  _STLP_STATIC_CONSTANT(int, radix = 2);  _STLP_STATIC_CONSTANT(bool, is_specialized = true);  _STLP_STATIC_CONSTANT(bool, is_signed = true);  _STLP_STATIC_CONSTANT(bool, is_integer = true);  _STLP_STATIC_CONSTANT(bool, is_exact = true);  _STLP_STATIC_CONSTANT(bool, is_bounded = true);  _STLP_STATIC_CONSTANT(bool, is_modulo = true);};_STLP_TEMPLATE_NULLclass numeric_limits<unsigned _STLP_LONG_LONG>  : public _STLP_PRIV _Numeric_limits_base<unsigned _STLP_LONG_LONG> {public:  static unsigned _STLP_LONG_LONG (_STLP_CALL min) () _STLP_NOTHROW { return 0ULL; }  static unsigned _STLP_LONG_LONG (_STLP_CALL max) () _STLP_NOTHROW { return ULONGLONG_MAX; }  _STLP_STATIC_CONSTANT(int, digits = ((int)((sizeof(unsigned _STLP_LONG_LONG) * (CHAR_BIT)))));  _STLP_STATIC_CONSTANT(int, digits10 = (digits * 301UL) / 1000);  _STLP_STATIC_CONSTANT(int, radix = 2);  _STLP_STATIC_CONSTANT(bool, is_specialized = true);  _STLP_STATIC_CONSTANT(bool, is_signed = false);  _STLP_STATIC_CONSTANT(bool, is_integer = true);  _STLP_STATIC_CONSTANT(bool, is_exact = true);  _STLP_STATIC_CONSTANT(bool, is_bounded = true);  _STLP_STATIC_CONSTANT(bool, is_modulo = true);};#  endif /* __GNUC__ > 2000-11-01 */#endif /* _STLP_LONG_LONG */_STLP_MOVE_TO_PRIV_NAMESPACE// Specializations for all built-in floating-point types.template <class __dummy>class _LimG {public:  static float _STLP_CALL get_F_inf();  static float _STLP_CALL get_F_qNaN();  static float _STLP_CALL get_F_sNaN();  static float _STLP_CALL get_F_denormMin();  static double _STLP_CALL get_D_inf();  static double _STLP_CALL get_D_qNaN();  static double _STLP_CALL get_D_sNaN();  static double _STLP_CALL get_D_denormMin();#if !defined (_STLP_NO_LONG_DOUBLE)  static long double _STLP_CALL get_LD_inf();  static long double _STLP_CALL get_LD_qNaN();  static long double _STLP_CALL get_LD_sNaN();  static long double _STLP_CALL get_LD_denormMin();#endif};#if defined (_STLP_USE_TEMPLATE_EXPORT)_STLP_EXPORT_TEMPLATE_CLASS _LimG<bool>;#endif#if defined (__GNUC__)#  if defined (__FLT_DENORM_MIN__)#    define _STLP_FLT_DENORM_MIN __FLT_DENORM_MIN__#  else#    define _STLP_FLT_DENORM_STYLE denorm_absent#  endif#  if defined (__DBL_DENORM_MIN__)#    define _STLP_DBL_DENORM_MIN __DBL_DENORM_MIN__#  else#    define _STLP_DBL_DENORM_STYLE denorm_absent#  endif#  if defined (__LDBL_DENORM_MIN__)#    define _STLP_LDBL_DENORM_MIN __LDBL_DENORM_MIN__#  else#    define _STLP_LDBL_DENORM_STYLE denorm_absent#  endif#endif/* If compiler do not expose thanks to some macro its status regarding * denormalized floating point numbers, we consider that denormalization * is present. Unit tests will tell us if compiler do not support them. */#if !defined (_STLP_FLT_DENORM_STYLE)#  define _STLP_FLT_DENORM_STYLE denorm_present#endif#if !defined (_STLP_DBL_DENORM_STYLE)#  define _STLP_DBL_DENORM_STYLE denorm_present#endif#if !defined (_STLP_LDBL_DENORM_STYLE)#  define _STLP_LDBL_DENORM_STYLE denorm_present#endif_STLP_MOVE_TO_STD_NAMESPACE_STLP_TEMPLATE_NULLclass numeric_limits<float>  : public _STLP_PRIV _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                                       true,                                       _STLP_FLT_DENORM_STYLE,                                       round_to_nearest> {public:  static float (_STLP_CALL min) () _STLP_NOTHROW { return FLT_MIN; }  static float _STLP_CALL denorm_min() _STLP_NOTHROW#if defined (_STLP_FLT_DENORM_MIN)  { return _STLP_FLT_DENORM_MIN; }#else  { return _STLP_FLT_DENORM_STYLE ? _STLP_PRIV _LimG<bool>::get_F_denormMin() : FLT_MIN; }#endif  static float (_STLP_CALL max) () _STLP_NOTHROW { return FLT_MAX; }  static float _STLP_CALL epsilon() _STLP_NOTHROW { return FLT_EPSILON; }  static float _STLP_CALL round_error() _STLP_NOTHROW { return 0.5f; } // Units: ulps.  static  float _STLP_CALL infinity() _STLP_NOTHROW { return _STLP_PRIV _LimG<bool>::get_F_inf(); }  static  float _STLP_CALL quiet_NaN() _STLP_NOTHROW { return _STLP_PRIV _LimG<bool>::get_F_qNaN(); }  static  float _STLP_CALL signaling_NaN() _STLP_NOTHROW { return _STLP_PRIV _LimG<bool>::get_F_sNaN(); }};#undef _STLP_FLT_DENORM_MIN#undef _STLP_FLT_DNORM_STYLE_STLP_TEMPLATE_NULLclass numeric_limits<double>  : public _STLP_PRIV _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                                       true,                                       _STLP_DBL_DENORM_STYLE,                                       round_to_nearest> {public:  static double (_STLP_CALL min)() _STLP_NOTHROW { return DBL_MIN; }  static double _STLP_CALL denorm_min() _STLP_NOTHROW#if defined (_STLP_DBL_DENORM_MIN)  { return _STLP_DBL_DENORM_MIN; }#else  { return _STLP_DBL_DENORM_STYLE ? _STLP_PRIV _LimG<bool>::get_D_denormMin() : DBL_MIN; }#endif  static double (_STLP_CALL max)() _STLP_NOTHROW { return DBL_MAX; }  static double _STLP_CALL epsilon() _STLP_NOTHROW { return DBL_EPSILON; }  static double _STLP_CALL round_error() _STLP_NOTHROW { return 0.5; } // Units: ulps.  static  double _STLP_CALL infinity() _STLP_NOTHROW { return _STLP_PRIV _LimG<bool>::get_D_inf(); }  static  double _STLP_CALL quiet_NaN() _STLP_NOTHROW { return _STLP_PRIV _LimG<bool>::get_D_qNaN(); }  static  double _STLP_CALL signaling_NaN() _STLP_NOTHROW { return _STLP_PRIV _LimG<bool>::get_D_sNaN(); }};#if !defined (_STLP_NO_LONG_DOUBLE)_STLP_TEMPLATE_NULLclass numeric_limits<long double>  : public _STLP_PRIV _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                                       false,          // do not conform to iec559                                       _STLP_LDBL_DENORM_STYLE,                                       round_to_nearest> {public:  static long double (_STLP_CALL min) () _STLP_NOTHROW { return LDBL_MIN; }  static long double _STLP_CALL denorm_min() _STLP_NOTHROW#if defined (_STLP_LDBL_DENORM_MIN)  { return _STLP_LDBL_DENORM_MIN; }#else  { return _STLP_LDBL_DENORM_STYLE ? _STLP_PRIV _LimG<bool>::get_LD_denormMin() : LDBL_MIN; }#endif  _STLP_STATIC_CONSTANT(bool, is_iec559 = false);  static long double (_STLP_CALL max) () _STLP_NOTHROW { return LDBL_MAX; }  static long double _STLP_CALL epsilon() _STLP_NOTHROW { return LDBL_EPSILON; }  static long double _STLP_CALL round_error() _STLP_NOTHROW { return 0.5l; }  static long double _STLP_CALL infinity() _STLP_NOTHROW  //For MSVC, long double is nothing more than an alias for double.#if !defined (_STLP_MSVC)  { return _STLP_PRIV _LimG<bool>::get_LD_inf(); }#else  { return _STLP_PRIV _LimG<bool>::get_D_inf(); }#endif  static long double _STLP_CALL quiet_NaN() _STLP_NOTHROW#if !defined (_STLP_MSVC)  { return _STLP_PRIV _LimG<bool>::get_LD_qNaN(); }#else  { return _STLP_PRIV _LimG<bool>::get_D_qNaN(); }#endif  static long double _STLP_CALL signaling_NaN() _STLP_NOTHROW#if !defined (_STLP_MSVC)  { return _STLP_PRIV _LimG<bool>::get_LD_sNaN(); }#else  { return _STLP_PRIV _LimG<bool>::get_D_sNaN(); }#endif};#endif// We write special values (Inf and NaN) as bit patterns and// cast the the appropriate floating-point types._STLP_END_NAMESPACE#if !defined (_STLP_LINK_TIME_INSTANTIATION)#  include <stl/_limits.c>#endif#endif// Local Variables:// mode:C++// End:

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?