⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 limits

📁 eVC stl 方便大家在evc中使用stl 帮助程序员更方便的编程。
💻
📖 第 1 页 / 共 2 页
字号:
/* * 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.  At present this file is suitable * for the MIPS and ia32 architectures. */#ifndef __SGI_CPP_LIMITS#define __SGI_CPP_LIMITS#include <limits.h>#include <float.h>#include <stl_config.h>__STL_BEGIN_NAMESPACEenum 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// __STL_STATIC_CONST_INIT_BUG 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 __STL_STATIC_CONST_INIT_BUG# define __STL_DECLARE_LIMITS_MEMBER(__mem_type, __mem_name, __mem_value) \  enum { __mem_name = __mem_value }#else /* __STL_STATIC_CONST_INIT_BUG */# define __STL_DECLARE_LIMITS_MEMBER(__mem_type, __mem_name, __mem_value) \  static const __mem_type __mem_name = __mem_value#endif /* __STL_STATIC_CONST_INIT_BUG */// Base class for all specializations of numeric_limits.template <class __number>class _Numeric_limits_base {public:  __STL_DECLARE_LIMITS_MEMBER(bool, is_specialized, false);  static __number min() __STL_NOTHROW { return __number(); }  static __number max() __STL_NOTHROW { return __number(); }  __STL_DECLARE_LIMITS_MEMBER(int, digits,   0);  __STL_DECLARE_LIMITS_MEMBER(int, digits10, 0);  __STL_DECLARE_LIMITS_MEMBER(bool, is_signed,  false);  __STL_DECLARE_LIMITS_MEMBER(bool, is_integer, false);  __STL_DECLARE_LIMITS_MEMBER(bool, is_exact,   false);  __STL_DECLARE_LIMITS_MEMBER(int, radix, 0);  static __number epsilon() __STL_NOTHROW     { return __number(); }  static __number round_error() __STL_NOTHROW { return __number(); }  __STL_DECLARE_LIMITS_MEMBER(int, min_exponent,   0);  __STL_DECLARE_LIMITS_MEMBER(int, min_exponent10, 0);  __STL_DECLARE_LIMITS_MEMBER(int, max_exponent,   0);  __STL_DECLARE_LIMITS_MEMBER(int, max_exponent10, 0);  __STL_DECLARE_LIMITS_MEMBER(bool, has_infinity,      false);  __STL_DECLARE_LIMITS_MEMBER(bool, has_quiet_NaN,     false);  __STL_DECLARE_LIMITS_MEMBER(bool, has_signaling_NaN, false);  __STL_DECLARE_LIMITS_MEMBER(float_denorm_style,                              has_denorm,                              denorm_absent);  __STL_DECLARE_LIMITS_MEMBER(bool, has_denorm_loss,   false);  static __number infinity() __STL_NOTHROW      { return __number(); }  static __number quiet_NaN() __STL_NOTHROW     { return __number(); }  static __number signaling_NaN() __STL_NOTHROW { return __number(); }  static __number denorm_min() __STL_NOTHROW    { return __number(); }  __STL_DECLARE_LIMITS_MEMBER(bool, is_iec559,  false);  __STL_DECLARE_LIMITS_MEMBER(bool, is_bounded, false);  __STL_DECLARE_LIMITS_MEMBER(bool, is_modulo,  false);  __STL_DECLARE_LIMITS_MEMBER(bool, traps,            false);  __STL_DECLARE_LIMITS_MEMBER(bool, tinyness_before,  false);  __STL_DECLARE_LIMITS_MEMBER(float_round_style,                              round_style,                              round_toward_zero);};#ifdef __STL_STATIC_CONST_INIT_BUG# define __STL_DEFINE_NUMERIC_BASE_MEMBER(__type, __mem)#else /* __STL_STATIC_CONST_INIT_BUG */# define __STL_DEFINE_NUMERIC_BASE_MEMBER(__type, __mem) \  template <class __number>                              \  const __type _Numeric_limits_base<__number>:: __mem#endif /* __STL_STATIC_CONST_INIT_BUG */__STL_DEFINE_NUMERIC_BASE_MEMBER(bool, is_specialized);__STL_DEFINE_NUMERIC_BASE_MEMBER(int, digits);__STL_DEFINE_NUMERIC_BASE_MEMBER(int, digits10);__STL_DEFINE_NUMERIC_BASE_MEMBER(bool, is_signed);__STL_DEFINE_NUMERIC_BASE_MEMBER(bool, is_integer);__STL_DEFINE_NUMERIC_BASE_MEMBER(bool, is_exact);__STL_DEFINE_NUMERIC_BASE_MEMBER(int, radix);__STL_DEFINE_NUMERIC_BASE_MEMBER(int, min_exponent);__STL_DEFINE_NUMERIC_BASE_MEMBER(int, max_exponent);__STL_DEFINE_NUMERIC_BASE_MEMBER(int, min_exponent10);__STL_DEFINE_NUMERIC_BASE_MEMBER(int, max_exponent10);__STL_DEFINE_NUMERIC_BASE_MEMBER(bool, has_infinity);__STL_DEFINE_NUMERIC_BASE_MEMBER(bool, has_quiet_NaN);__STL_DEFINE_NUMERIC_BASE_MEMBER(bool, has_signaling_NaN);__STL_DEFINE_NUMERIC_BASE_MEMBER(float_denorm_style, has_denorm);__STL_DEFINE_NUMERIC_BASE_MEMBER(bool, has_denorm_loss);__STL_DEFINE_NUMERIC_BASE_MEMBER(bool, is_iec559);__STL_DEFINE_NUMERIC_BASE_MEMBER(bool, is_bounded);__STL_DEFINE_NUMERIC_BASE_MEMBER(bool, is_modulo);__STL_DEFINE_NUMERIC_BASE_MEMBER(bool, traps);__STL_DEFINE_NUMERIC_BASE_MEMBER(bool, tinyness_before);__STL_DEFINE_NUMERIC_BASE_MEMBER(float_round_style, round_style);// Base class for integers.template <class _Int,          _Int __imin, _Int __imax,          int __idigits = -1, bool __ismod = true>class _Integer_limits : public _Numeric_limits_base<_Int> {public:  __STL_DECLARE_LIMITS_MEMBER(bool, is_specialized, true);  static _Int min() __STL_NOTHROW { return __imin; }  static _Int max() __STL_NOTHROW { return __imax; }  __STL_DECLARE_LIMITS_MEMBER(int,                              digits,                              (__idigits < 0) ? (int)(sizeof(_Int) * CHAR_BIT)                                                   - (__imin == 0 ? 0 : 1)                                               : __idigits);  __STL_DECLARE_LIMITS_MEMBER(int, digits10, (digits * 301) / 1000);                                 // log 2 = 0.301029995664...  __STL_DECLARE_LIMITS_MEMBER(bool, is_signed,  __imin != 0);  __STL_DECLARE_LIMITS_MEMBER(bool, is_integer, true);  __STL_DECLARE_LIMITS_MEMBER(bool, is_exact,   true);  __STL_DECLARE_LIMITS_MEMBER(int,  radix,      2);  __STL_DECLARE_LIMITS_MEMBER(bool, is_bounded, true);  __STL_DECLARE_LIMITS_MEMBER(bool, is_modulo, __ismod);};#ifdef __STL_STATIC_CONST_INIT_BUG# define __STL_DEFINE_INTEGER_LIMITS_MEMBER(__type, __mem)#else /* __STL_STATIC_CONST_INIT_BUG */# define __STL_DEFINE_INTEGER_LIMITS_MEMBER(__type, __mem)              \  template <class _Int, _Int __imin, _Int __imax, int __idig, bool __ismod>  \  const __type _Integer_limits<_Int, __imin, __imax, __idig, __ismod>::__mem#endif /* __STL_STATIC_CONST_INIT_BUG */__STL_DEFINE_INTEGER_LIMITS_MEMBER(bool, is_specialized);__STL_DEFINE_INTEGER_LIMITS_MEMBER(int, digits);__STL_DEFINE_INTEGER_LIMITS_MEMBER(int, digits10);__STL_DEFINE_INTEGER_LIMITS_MEMBER(bool, is_signed);__STL_DEFINE_INTEGER_LIMITS_MEMBER(bool, is_integer);__STL_DEFINE_INTEGER_LIMITS_MEMBER(bool, is_exact);__STL_DEFINE_INTEGER_LIMITS_MEMBER(int, radix);__STL_DEFINE_INTEGER_LIMITS_MEMBER(bool, is_bounded);__STL_DEFINE_INTEGER_LIMITS_MEMBER(bool, is_modulo);// Base class for floating-point numbers.template <class __number,         int __Digits, int __Digits10,         int __MinExp, int __MaxExp,         int __MinExp10, int __MaxExp10,         bool __IsIEC559,         float_round_style __RoundStyle>class _Floating_limits : public _Numeric_limits_base<__number>{public:  __STL_DECLARE_LIMITS_MEMBER(bool, is_specialized, true);  __STL_DECLARE_LIMITS_MEMBER(int, digits,   __Digits);  __STL_DECLARE_LIMITS_MEMBER(int, digits10, __Digits10);  __STL_DECLARE_LIMITS_MEMBER(bool, is_signed, true);  __STL_DECLARE_LIMITS_MEMBER(int, radix, 2);  __STL_DECLARE_LIMITS_MEMBER(int, min_exponent,   __MinExp);  __STL_DECLARE_LIMITS_MEMBER(int, max_exponent,   __MaxExp);  __STL_DECLARE_LIMITS_MEMBER(int, min_exponent10, __MinExp10);  __STL_DECLARE_LIMITS_MEMBER(int, max_exponent10, __MaxExp10);  __STL_DECLARE_LIMITS_MEMBER(bool, has_infinity,      true);  __STL_DECLARE_LIMITS_MEMBER(bool, has_quiet_NaN,     true);  __STL_DECLARE_LIMITS_MEMBER(bool, has_signaling_NaN, true);  __STL_DECLARE_LIMITS_MEMBER(float_denorm_style,                              has_denorm,                              denorm_indeterminate);  __STL_DECLARE_LIMITS_MEMBER(bool, has_denorm_loss,   false);  __STL_DECLARE_LIMITS_MEMBER(bool, is_iec559,       __IsIEC559);  __STL_DECLARE_LIMITS_MEMBER(bool, is_bounded,      true);  __STL_DECLARE_LIMITS_MEMBER(bool, traps,           true);  __STL_DECLARE_LIMITS_MEMBER(bool, tinyness_before, false);  __STL_DECLARE_LIMITS_MEMBER(float_round_style, round_style, __RoundStyle);};#ifdef __STL_STATIC_CONST_INIT_BUG# define __STL_DEFINE_FLOAT_LIMITS_MEMBER(__type, __mem)#else /* __STL_STATIC_CONST_INIT_BUG */# define __STL_DEFINE_FLOAT_LIMITS_MEMBER(__type, __mem)                   \  template <class __Num, int __Dig, int __Dig10,                           \            int __MnX, int __MxX, int __MnX10, int __MxX10,                \            bool __IsIEEE, float_round_style __Sty>                        \  const __type _Floating_limits<__Num, __Dig, __Dig10,                     \                                __MnX, __MxX, __MnX10, __MxX10,            \                                __IsIEEE, __Sty>:: __mem#endif /* __STL_STATIC_CONST_INIT_BUG */__STL_DEFINE_FLOAT_LIMITS_MEMBER(bool, is_specialized);  __STL_DEFINE_FLOAT_LIMITS_MEMBER(int, digits);  __STL_DEFINE_FLOAT_LIMITS_MEMBER(int, digits10);  __STL_DEFINE_FLOAT_LIMITS_MEMBER(bool, is_signed);  __STL_DEFINE_FLOAT_LIMITS_MEMBER(int, radix);  __STL_DEFINE_FLOAT_LIMITS_MEMBER(int, min_exponent);  __STL_DEFINE_FLOAT_LIMITS_MEMBER(int, max_exponent);  __STL_DEFINE_FLOAT_LIMITS_MEMBER(int, min_exponent10);  __STL_DEFINE_FLOAT_LIMITS_MEMBER(int, max_exponent10);  __STL_DEFINE_FLOAT_LIMITS_MEMBER(bool, has_infinity);__STL_DEFINE_FLOAT_LIMITS_MEMBER(bool, has_quiet_NaN);__STL_DEFINE_FLOAT_LIMITS_MEMBER(bool, has_signaling_NaN);__STL_DEFINE_FLOAT_LIMITS_MEMBER(float_denorm_style, has_denorm);__STL_DEFINE_FLOAT_LIMITS_MEMBER(bool, has_denorm_loss);__STL_DEFINE_FLOAT_LIMITS_MEMBER(bool, is_iec559);__STL_DEFINE_FLOAT_LIMITS_MEMBER(bool, is_bounded);__STL_DEFINE_FLOAT_LIMITS_MEMBER(bool, traps);__STL_DEFINE_FLOAT_LIMITS_MEMBER(bool, tinyness_before);__STL_DEFINE_FLOAT_LIMITS_MEMBER(float_round_style, round_style);#undef __STL_DECLARE_NUMERIC_LIMITS_MEMBER#undef __STL_DEFINE_NUMERIC_BASE_MEMBER

⌨️ 快捷键说明

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