diff options
author | Ed Smith-Rowland <3dw4rd@verizon.net> | 2010-02-25 17:13:04 +0000 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2010-02-25 17:13:04 +0000 |
commit | 018afad39fc0b88d5bfd4842efa52a7923cff371 (patch) | |
tree | 6d04dd4a6cc534ecc9f708196c65ef2558d9e02c /libstdc++-v3 | |
parent | 640f8e65484943a0bc1c2c47cdbee438fc40b8ad (diff) | |
download | gcc-018afad39fc0b88d5bfd4842efa52a7923cff371.zip gcc-018afad39fc0b88d5bfd4842efa52a7923cff371.tar.gz gcc-018afad39fc0b88d5bfd4842efa52a7923cff371.tar.bz2 |
limits (__numeric_limits_base::max_digits10, [...]): Add.
2010-02-25 Ed Smith-Rowland <3dw4rd@verizon.net>
* include/std/limits (__numeric_limits_base::max_digits10,
numeric_limits<>::max_digits10, numeric_limits<>::lowest): Add.
* src/limits.cc: Define max_digits10.
* config/abi/pre/gnu.ver: Adjust.
* testsuite/18_support/numeric_limits/dr559.cc: Test max_digits10
and lowest too.
* testsuite/18_support/numeric_limits/lowest.cc: New.
* testsuite/18_support/numeric_limits/max_digits10.cc: New.
From-SVN: r157067
Diffstat (limited to 'libstdc++-v3')
-rw-r--r-- | libstdc++-v3/ChangeLog | 11 | ||||
-rw-r--r-- | libstdc++-v3/config/abi/pre/gnu.ver | 29 | ||||
-rw-r--r-- | libstdc++-v3/include/std/limits | 146 | ||||
-rw-r--r-- | libstdc++-v3/src/limits.cc | 19 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/18_support/numeric_limits/dr559.cc | 2 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/18_support/numeric_limits/lowest.cc | 82 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/18_support/numeric_limits/max_digits10.cc | 67 |
7 files changed, 349 insertions, 7 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index d363282..f66cb34 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,14 @@ +2010-02-25 Ed Smith-Rowland <3dw4rd@verizon.net> + + * include/std/limits (__numeric_limits_base::max_digits10, + numeric_limits<>::max_digits10, numeric_limits<>::lowest): Add. + * src/limits.cc: Define max_digits10. + * config/abi/pre/gnu.ver: Adjust. + * testsuite/18_support/numeric_limits/dr559.cc: Test max_digits10 + and lowest too. + * testsuite/18_support/numeric_limits/lowest.cc: New. + * testsuite/18_support/numeric_limits/max_digits10.cc: New. + 2010-02-25 Paolo Carlini <paolo.carlini@oracle.com> * include/bits/functional_hash.h (__hash_combine): Remove. diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver index 9d3ff47..1df6499 100644 --- a/libstdc++-v3/config/abi/pre/gnu.ver +++ b/libstdc++-v3/config/abi/pre/gnu.ver @@ -164,7 +164,7 @@ GLIBCXX_3.4 { std::_List_node_base::reverse*; std::_List_node_base::transfer*; std::__timepunct*; - std::__numeric_limits_base*; +# std::__numeric_limits_base*; std::__num_base::_S_format_float*; std::__num_base::_S_format_int*; std::__num_base::_S_atoms_in; @@ -476,7 +476,15 @@ GLIBCXX_3.4 { _ZNSt15time_put_byname*; # std::numeric_limits - _ZNSt14numeric_limitsI[^g]E*; + _ZNSt21__numeric_limits_base[5-9]*; + _ZNSt21__numeric_limits_base1[0-7][hirt]*; + _ZNSt21__numeric_limits_base1[0-7]mi*; + _ZNSt21__numeric_limits_base1[0-7]max_e*; + + _ZNSt14numeric_limitsI[^g]E[5-9]*; + _ZNSt14numeric_limitsI[^g]E1[0-7][hirt]*; + _ZNSt14numeric_limitsI[^g]E1[0-7]mi*; + _ZNSt14numeric_limitsI[^g]E1[0-7]max_e*; # std::_Rb_tree _ZSt18_Rb_tree_decrementPKSt18_Rb_tree_node_base; @@ -1010,8 +1018,14 @@ GLIBCXX_3.4.11 { _ZSt20__throw_system_errori; # char16_t and char32_t - _ZNSt14numeric_limitsIDiE*; - _ZNSt14numeric_limitsIDsE*; + _ZNSt14numeric_limitsIDiE[5-9]*; + _ZNSt14numeric_limitsIDsE[5-9]*; + _ZNSt14numeric_limitsIDiE1[0-7][hirt]*; + _ZNSt14numeric_limitsIDsE1[0-7][hirt]*; + _ZNSt14numeric_limitsIDiE1[0-7]mi*; + _ZNSt14numeric_limitsIDsE1[0-7]mi*; + _ZNSt14numeric_limitsIDiE1[0-7]max_e*; + _ZNSt14numeric_limitsIDsE1[0-7]max_e*; # chrono _ZNSt6chrono12system_clock12is_monotonicE; @@ -1128,8 +1142,15 @@ GLIBCXX_3.4.14 { _ZNSt9__cxx199815_List_node_base9_M_unhookEv; _ZNSt9__cxx199815_List_node_base10_M_reverseEv; _ZNSt9__cxx199815_List_node_base11_M_transfer*; + + # std::numeric_limits::max_digits10 + _ZNSt21__numeric_limits_base12max_digits10E; + _ZNSt14numeric_limitsI[^g]E12max_digits10E; + _ZNSt14numeric_limitsID[is]E12max_digits10E; + } GLIBCXX_3.4.13; + # Symbols in the support library (libsupc++) have their own tag. CXXABI_1.3 { diff --git a/libstdc++-v3/include/std/limits b/libstdc++-v3/include/std/limits index a633d78..65b623e 100644 --- a/libstdc++-v3/include/std/limits +++ b/libstdc++-v3/include/std/limits @@ -142,6 +142,8 @@ #define __glibcxx_digits10(T) \ (__glibcxx_digits (T) * 643 / 2136) +#define __glibcxx_max_digits10(T) \ + (2 + (T) * 643 / 2136) _GLIBCXX_BEGIN_NAMESPACE(std) @@ -197,11 +199,15 @@ _GLIBCXX_BEGIN_NAMESPACE(std) static const int digits = 0; /** The number of base 10 digits that can be represented without change. */ static const int digits10 = 0; +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + /** The number of base 10 digits required to ensure that values which + differ are always differentiated. */ + static const int max_digits10 = 0; +#endif /** True if the type is signed. */ static const bool is_signed = false; /** True if the type is integer. - * Is this supposed to be <em>if the type is integral?</em> - */ + * Is this supposed to be <em>if the type is integral?</em> */ static const bool is_integer = false; /** True if the type uses an exact representation. <em>All integer types are exact, but not all exact types are integer. For example, rational and @@ -282,6 +288,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) static _Tp min() throw() { return static_cast<_Tp>(0); } /** The maximum finite value. */ static _Tp max() throw() { return static_cast<_Tp>(0); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + /** A finite value x such that there is no other finite value y + * where y < x. */ + static _Tp lowest() throw() { return static_cast<_Tp>(0); } +#endif /** The @e machine @e epsilon: the difference between 1 and the least value greater than 1 that is representable. */ static _Tp epsilon() throw() { return static_cast<_Tp>(0); } @@ -329,9 +340,15 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { return false; } static bool max() throw() { return true; } - +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + static bool lowest() throw() + { return min(); } +#endif static const int digits = 1; static const int digits10 = 0; +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + static const int max_digits10 = 0; +#endif static const bool is_signed = false; static const bool is_integer = true; static const bool is_exact = true; @@ -383,9 +400,16 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { return __glibcxx_min(char); } static char max() throw() { return __glibcxx_max(char); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + static char lowest() throw() + { return min(); } +#endif static const int digits = __glibcxx_digits (char); static const int digits10 = __glibcxx_digits10 (char); +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + static const int max_digits10 = 0; +#endif static const bool is_signed = __glibcxx_signed (char); static const bool is_integer = true; static const bool is_exact = true; @@ -434,9 +458,16 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { return -__SCHAR_MAX__ - 1; } static signed char max() throw() { return __SCHAR_MAX__; } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + static signed char lowest() throw() + { return min(); } +#endif static const int digits = __glibcxx_digits (signed char); static const int digits10 = __glibcxx_digits10 (signed char); +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + static const int max_digits10 = 0; +#endif static const bool is_signed = true; static const bool is_integer = true; static const bool is_exact = true; @@ -485,9 +516,16 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { return 0; } static unsigned char max() throw() { return __SCHAR_MAX__ * 2U + 1; } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + static unsigned char lowest() throw() + { return min(); } +#endif static const int digits = __glibcxx_digits (unsigned char); static const int digits10 = __glibcxx_digits10 (unsigned char); +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + static const int max_digits10 = 0; +#endif static const bool is_signed = false; static const bool is_integer = true; static const bool is_exact = true; @@ -536,9 +574,16 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { return __glibcxx_min (wchar_t); } static wchar_t max() throw() { return __glibcxx_max (wchar_t); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + static wchar_t lowest() throw() + { return min(); } +#endif static const int digits = __glibcxx_digits (wchar_t); static const int digits10 = __glibcxx_digits10 (wchar_t); +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + static const int max_digits10 = 0; +#endif static const bool is_signed = __glibcxx_signed (wchar_t); static const bool is_integer = true; static const bool is_exact = true; @@ -588,9 +633,16 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { return __glibcxx_min (char16_t); } static char16_t max() throw() { return __glibcxx_max (char16_t); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + static char16_t lowest() throw() + { return min(); } +#endif static const int digits = __glibcxx_digits (char16_t); static const int digits10 = __glibcxx_digits10 (char16_t); +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + static const int max_digits10 = 0; +#endif static const bool is_signed = __glibcxx_signed (char16_t); static const bool is_integer = true; static const bool is_exact = true; @@ -639,9 +691,16 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { return __glibcxx_min (char32_t); } static char32_t max() throw() { return __glibcxx_max (char32_t); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + static char32_t lowest() throw() + { return min(); } +#endif static const int digits = __glibcxx_digits (char32_t); static const int digits10 = __glibcxx_digits10 (char32_t); +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + static const int max_digits10 = 0; +#endif static const bool is_signed = __glibcxx_signed (char32_t); static const bool is_integer = true; static const bool is_exact = true; @@ -691,9 +750,16 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { return -__SHRT_MAX__ - 1; } static short max() throw() { return __SHRT_MAX__; } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + static short lowest() throw() + { return min(); } +#endif static const int digits = __glibcxx_digits (short); static const int digits10 = __glibcxx_digits10 (short); +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + static const int max_digits10 = 0; +#endif static const bool is_signed = true; static const bool is_integer = true; static const bool is_exact = true; @@ -742,9 +808,16 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { return 0; } static unsigned short max() throw() { return __SHRT_MAX__ * 2U + 1; } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + static unsigned short lowest() throw() + { return min(); } +#endif static const int digits = __glibcxx_digits (unsigned short); static const int digits10 = __glibcxx_digits10 (unsigned short); +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + static const int max_digits10 = 0; +#endif static const bool is_signed = false; static const bool is_integer = true; static const bool is_exact = true; @@ -793,9 +866,16 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { return -__INT_MAX__ - 1; } static int max() throw() { return __INT_MAX__; } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + static int lowest() throw() + { return min(); } +#endif static const int digits = __glibcxx_digits (int); static const int digits10 = __glibcxx_digits10 (int); +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + static const int max_digits10 = 0; +#endif static const bool is_signed = true; static const bool is_integer = true; static const bool is_exact = true; @@ -844,9 +924,16 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { return 0; } static unsigned int max() throw() { return __INT_MAX__ * 2U + 1; } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + static unsigned int lowest() throw() + { return min(); } +#endif static const int digits = __glibcxx_digits (unsigned int); static const int digits10 = __glibcxx_digits10 (unsigned int); +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + static const int max_digits10 = 0; +#endif static const bool is_signed = false; static const bool is_integer = true; static const bool is_exact = true; @@ -895,9 +982,16 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { return -__LONG_MAX__ - 1; } static long max() throw() { return __LONG_MAX__; } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + static long lowest() throw() + { return min(); } +#endif static const int digits = __glibcxx_digits (long); static const int digits10 = __glibcxx_digits10 (long); +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + static const int max_digits10 = 0; +#endif static const bool is_signed = true; static const bool is_integer = true; static const bool is_exact = true; @@ -946,9 +1040,16 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { return 0; } static unsigned long max() throw() { return __LONG_MAX__ * 2UL + 1; } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + static unsigned long lowest() throw() + { return min(); } +#endif static const int digits = __glibcxx_digits (unsigned long); static const int digits10 = __glibcxx_digits10 (unsigned long); +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + static const int max_digits10 = 0; +#endif static const bool is_signed = false; static const bool is_integer = true; static const bool is_exact = true; @@ -997,9 +1098,16 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { return -__LONG_LONG_MAX__ - 1; } static long long max() throw() { return __LONG_LONG_MAX__; } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + static long long lowest() throw() + { return min(); } +#endif static const int digits = __glibcxx_digits (long long); static const int digits10 = __glibcxx_digits10 (long long); +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + static const int max_digits10 = 0; +#endif static const bool is_signed = true; static const bool is_integer = true; static const bool is_exact = true; @@ -1048,9 +1156,16 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { return 0; } static unsigned long long max() throw() { return __LONG_LONG_MAX__ * 2ULL + 1; } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + static unsigned long long lowest() throw() + { return min(); } +#endif static const int digits = __glibcxx_digits (unsigned long long); static const int digits10 = __glibcxx_digits10 (unsigned long long); +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + static const int max_digits10 = 0; +#endif static const bool is_signed = false; static const bool is_integer = true; static const bool is_exact = true; @@ -1099,9 +1214,17 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { return __FLT_MIN__; } static float max() throw() { return __FLT_MAX__; } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + static float lowest() throw() + { return -__FLT_MAX__; } +#endif static const int digits = __FLT_MANT_DIG__; static const int digits10 = __FLT_DIG__; +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + static const int max_digits10 + = __glibcxx_max_digits10 (__FLT_MANT_DIG__); +#endif static const bool is_signed = true; static const bool is_integer = false; static const bool is_exact = false; @@ -1156,9 +1279,17 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { return __DBL_MIN__; } static double max() throw() { return __DBL_MAX__; } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + static double lowest() throw() + { return -__DBL_MAX__; } +#endif static const int digits = __DBL_MANT_DIG__; static const int digits10 = __DBL_DIG__; +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + static const int max_digits10 + = __glibcxx_max_digits10 (__DBL_MANT_DIG__); +#endif static const bool is_signed = true; static const bool is_integer = false; static const bool is_exact = false; @@ -1213,9 +1344,17 @@ _GLIBCXX_BEGIN_NAMESPACE(std) { return __LDBL_MIN__; } static long double max() throw() { return __LDBL_MAX__; } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + static long double lowest() throw() + { return -__LDBL_MAX__; } +#endif static const int digits = __LDBL_MANT_DIG__; static const int digits10 = __LDBL_DIG__; +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + static const int max_digits10 + = __glibcxx_max_digits10 (__LDBL_MANT_DIG__); +#endif static const bool is_signed = true; static const bool is_integer = false; static const bool is_exact = false; @@ -1268,5 +1407,6 @@ _GLIBCXX_END_NAMESPACE #undef __glibcxx_max #undef __glibcxx_digits #undef __glibcxx_digits10 +#undef __glibcxx_max_digits10 #endif // _GLIBCXX_NUMERIC_LIMITS diff --git a/libstdc++-v3/src/limits.cc b/libstdc++-v3/src/limits.cc index 09a5dae..9c953c9 100644 --- a/libstdc++-v3/src/limits.cc +++ b/libstdc++-v3/src/limits.cc @@ -37,6 +37,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) const bool __numeric_limits_base::is_specialized; const int __numeric_limits_base::digits; const int __numeric_limits_base::digits10; + const int __numeric_limits_base::max_digits10; const bool __numeric_limits_base::is_signed; const bool __numeric_limits_base::is_integer; const bool __numeric_limits_base::is_exact; @@ -61,6 +62,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) const bool numeric_limits<bool>::is_specialized; const int numeric_limits<bool>::digits; const int numeric_limits<bool>::digits10; + const int numeric_limits<bool>::max_digits10; const bool numeric_limits<bool>::is_signed; const bool numeric_limits<bool>::is_integer; const bool numeric_limits<bool>::is_exact; @@ -85,6 +87,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) const bool numeric_limits<char>::is_specialized; const int numeric_limits<char>::digits; const int numeric_limits<char>::digits10; + const int numeric_limits<char>::max_digits10; const bool numeric_limits<char>::is_signed; const bool numeric_limits<char>::is_integer; const bool numeric_limits<char>::is_exact; @@ -109,6 +112,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) const bool numeric_limits<signed char>::is_specialized; const int numeric_limits<signed char>::digits; const int numeric_limits<signed char>::digits10; + const int numeric_limits<signed char>::max_digits10; const bool numeric_limits<signed char>::is_signed; const bool numeric_limits<signed char>::is_integer; const bool numeric_limits<signed char>::is_exact; @@ -133,6 +137,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) const bool numeric_limits<unsigned char>::is_specialized; const int numeric_limits<unsigned char>::digits; const int numeric_limits<unsigned char>::digits10; + const int numeric_limits<unsigned char>::max_digits10; const bool numeric_limits<unsigned char>::is_signed; const bool numeric_limits<unsigned char>::is_integer; const bool numeric_limits<unsigned char>::is_exact; @@ -159,6 +164,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) const bool numeric_limits<wchar_t>::is_specialized; const int numeric_limits<wchar_t>::digits; const int numeric_limits<wchar_t>::digits10; + const int numeric_limits<wchar_t>::max_digits10; const bool numeric_limits<wchar_t>::is_signed; const bool numeric_limits<wchar_t>::is_integer; const bool numeric_limits<wchar_t>::is_exact; @@ -184,6 +190,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) const bool numeric_limits<short>::is_specialized; const int numeric_limits<short>::digits; const int numeric_limits<short>::digits10; + const int numeric_limits<short>::max_digits10; const bool numeric_limits<short>::is_signed; const bool numeric_limits<short>::is_integer; const bool numeric_limits<short>::is_exact; @@ -208,6 +215,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) const bool numeric_limits<unsigned short>::is_specialized; const int numeric_limits<unsigned short>::digits; const int numeric_limits<unsigned short>::digits10; + const int numeric_limits<unsigned short>::max_digits10; const bool numeric_limits<unsigned short>::is_signed; const bool numeric_limits<unsigned short>::is_integer; const bool numeric_limits<unsigned short>::is_exact; @@ -232,6 +240,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) const bool numeric_limits<int>::is_specialized; const int numeric_limits<int>::digits; const int numeric_limits<int>::digits10; + const int numeric_limits<int>::max_digits10; const bool numeric_limits<int>::is_signed; const bool numeric_limits<int>::is_integer; const bool numeric_limits<int>::is_exact; @@ -256,6 +265,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) const bool numeric_limits<unsigned int>::is_specialized; const int numeric_limits<unsigned int>::digits; const int numeric_limits<unsigned int>::digits10; + const int numeric_limits<unsigned int>::max_digits10; const bool numeric_limits<unsigned int>::is_signed; const bool numeric_limits<unsigned int>::is_integer; const bool numeric_limits<unsigned int>::is_exact; @@ -280,6 +290,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) const bool numeric_limits<long>::is_specialized; const int numeric_limits<long>::digits; const int numeric_limits<long>::digits10; + const int numeric_limits<long>::max_digits10; const bool numeric_limits<long>::is_signed; const bool numeric_limits<long>::is_integer; const bool numeric_limits<long>::is_exact; @@ -304,6 +315,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) const bool numeric_limits<unsigned long>::is_specialized; const int numeric_limits<unsigned long>::digits; const int numeric_limits<unsigned long>::digits10; + const int numeric_limits<unsigned long>::max_digits10; const bool numeric_limits<unsigned long>::is_signed; const bool numeric_limits<unsigned long>::is_integer; const bool numeric_limits<unsigned long>::is_exact; @@ -328,6 +340,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) const bool numeric_limits<long long>::is_specialized; const int numeric_limits<long long>::digits; const int numeric_limits<long long>::digits10; + const int numeric_limits<long long>::max_digits10; const bool numeric_limits<long long>::is_signed; const bool numeric_limits<long long>::is_integer; const bool numeric_limits<long long>::is_exact; @@ -351,6 +364,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) const bool numeric_limits<unsigned long long>::is_specialized; const int numeric_limits<unsigned long long>::digits; const int numeric_limits<unsigned long long>::digits10; + const int numeric_limits<unsigned long long>::max_digits10; const bool numeric_limits<unsigned long long>::is_signed; const bool numeric_limits<unsigned long long>::is_integer; const bool numeric_limits<unsigned long long>::is_exact; @@ -375,6 +389,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) const bool numeric_limits<float>::is_specialized; const int numeric_limits<float>::digits; const int numeric_limits<float>::digits10; + const int numeric_limits<float>::max_digits10; const bool numeric_limits<float>::is_signed; const bool numeric_limits<float>::is_integer; const bool numeric_limits<float>::is_exact; @@ -399,6 +414,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) const bool numeric_limits<double>::is_specialized; const int numeric_limits<double>::digits; const int numeric_limits<double>::digits10; + const int numeric_limits<double>::max_digits10; const bool numeric_limits<double>::is_signed; const bool numeric_limits<double>::is_integer; const bool numeric_limits<double>::is_exact; @@ -423,6 +439,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) const bool numeric_limits<long double>::is_specialized; const int numeric_limits<long double>::digits; const int numeric_limits<long double>::digits10; + const int numeric_limits<long double>::max_digits10; const bool numeric_limits<long double>::is_signed; const bool numeric_limits<long double>::is_integer; const bool numeric_limits<long double>::is_exact; @@ -447,6 +464,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) const bool numeric_limits<char16_t>::is_specialized; const int numeric_limits<char16_t>::digits; const int numeric_limits<char16_t>::digits10; + const int numeric_limits<char16_t>::max_digits10; const bool numeric_limits<char16_t>::is_signed; const bool numeric_limits<char16_t>::is_integer; const bool numeric_limits<char16_t>::is_exact; @@ -471,6 +489,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) const bool numeric_limits<char32_t>::is_specialized; const int numeric_limits<char32_t>::digits; const int numeric_limits<char32_t>::digits10; + const int numeric_limits<char32_t>::max_digits10; const bool numeric_limits<char32_t>::is_signed; const bool numeric_limits<char32_t>::is_integer; const bool numeric_limits<char32_t>::is_exact; diff --git a/libstdc++-v3/testsuite/18_support/numeric_limits/dr559.cc b/libstdc++-v3/testsuite/18_support/numeric_limits/dr559.cc index f541faa..ffe5a4b 100644 --- a/libstdc++-v3/testsuite/18_support/numeric_limits/dr559.cc +++ b/libstdc++-v3/testsuite/18_support/numeric_limits/dr559.cc @@ -33,8 +33,10 @@ template<typename T> VERIFY( cv_limits::is_specialized == limits::is_specialized ); VERIFY( cv_limits::min() == limits::min() ); VERIFY( cv_limits::max() == limits::max() ); + VERIFY( cv_limits::lowest() == limits::lowest() ); VERIFY( cv_limits::digits == limits::digits ); VERIFY( cv_limits::digits10 == limits::digits10 ); + VERIFY( cv_limits::max_digits10 == limits::max_digits10 ); VERIFY( cv_limits::is_signed == limits::is_signed ); VERIFY( cv_limits::is_integer == limits::is_integer ); VERIFY( cv_limits::is_exact == limits::is_exact ); diff --git a/libstdc++-v3/testsuite/18_support/numeric_limits/lowest.cc b/libstdc++-v3/testsuite/18_support/numeric_limits/lowest.cc new file mode 100644 index 0000000..498a03b --- /dev/null +++ b/libstdc++-v3/testsuite/18_support/numeric_limits/lowest.cc @@ -0,0 +1,82 @@ +// { dg-options "-std=gnu++0x" } +// { dg-add-options ieee } + +// 2010-02-25 Ed Smith-Rowland + +// Copyright (C) 2010 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 18.2.1.1 template class numeric_limits + +#include <limits> +#include <type_traits> +#include <testsuite_hooks.h> + +template<typename T> + void + do_test(std::true_type) + { + bool test __attribute__((unused)) = true; + T limits_min = std::numeric_limits<T>::min(); + VERIFY( std::numeric_limits<T>::lowest() == limits_min ); + } + +template<typename T> + void + do_test(std::false_type) + { + bool test __attribute__((unused)) = true; + T limits_max = std::numeric_limits<T>::max(); + VERIFY( std::numeric_limits<T>::lowest() == -limits_max ); + } + +template<typename Tp> + void + do_test() + { do_test<Tp>(typename std::is_integral<Tp>::type()); } + +void test01() +{ + do_test<char>(); + do_test<signed char>(); + do_test<unsigned char>(); + do_test<wchar_t>(); + do_test<char16_t>(); + do_test<char32_t>(); + + do_test<short>(); + do_test<unsigned short>(); + + do_test<int>(); + do_test<unsigned int>(); + + do_test<long>(); + do_test<unsigned long>(); + + do_test<long long>(); + do_test<unsigned long long>(); + + do_test<float>(); + do_test<double>(); + do_test<long double>(); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/18_support/numeric_limits/max_digits10.cc b/libstdc++-v3/testsuite/18_support/numeric_limits/max_digits10.cc new file mode 100644 index 0000000..fdce19c --- /dev/null +++ b/libstdc++-v3/testsuite/18_support/numeric_limits/max_digits10.cc @@ -0,0 +1,67 @@ +// { dg-options "-std=gnu++0x" } +// { dg-add-options ieee } + +// 2010-02-25 Ed Smith-Rowland + +// Copyright (C) 2010 Free Software Foundation +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// 18.2.1.1 template class numeric_limits + +#include <limits> +#include <cmath> +#include <testsuite_hooks.h> + +void +test01() +{ + bool test __attribute__((unused)) = true; + + VERIFY( std::numeric_limits<bool>::max_digits10 == 0 ); + VERIFY( std::numeric_limits<char>::max_digits10 == 0 ); + VERIFY( std::numeric_limits<signed char>::max_digits10 == 0 ); + VERIFY( std::numeric_limits<unsigned char>::max_digits10 == 0 ); + VERIFY( std::numeric_limits<wchar_t>::max_digits10 == 0 ); + VERIFY( std::numeric_limits<short>::max_digits10 == 0 ); + VERIFY( std::numeric_limits<unsigned short>::max_digits10 == 0 ); + VERIFY( std::numeric_limits<int>::max_digits10 == 0 ); + VERIFY( std::numeric_limits<unsigned int>::max_digits10 == 0 ); + VERIFY( std::numeric_limits<long>::max_digits10 == 0 ); + VERIFY( std::numeric_limits<unsigned long>::max_digits10 == 0 ); + VERIFY( std::numeric_limits<long long>::max_digits10 == 0 ); + VERIFY( std::numeric_limits<unsigned long long>::max_digits10 == 0 ); + VERIFY( std::numeric_limits<char16_t>::max_digits10 == 0 ); + VERIFY( std::numeric_limits<char32_t>::max_digits10 == 0 ); + + const int f_max_digits10 = (2 + std::numeric_limits<float>::digits + * 643 / 2136); + VERIFY( std::numeric_limits<float>::max_digits10 == f_max_digits10 ); + + const int d_max_digits10 = (2 + std::numeric_limits<double>::digits + * 643 / 2136); + VERIFY( std::numeric_limits<double>::max_digits10 == d_max_digits10 ); + + const int ld_max_digits10 = (2 + std::numeric_limits<long double>::digits + * 643 / 2136); + VERIFY( std::numeric_limits<long double>::max_digits10 == ld_max_digits10 ); +} + +int main() +{ + test01(); + return 0; +} |