29 #ifndef _EXT_NUMERIC_TRAITS 30 #define _EXT_NUMERIC_TRAITS 1 32 #pragma GCC system_header 37 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
39 _GLIBCXX_BEGIN_NAMESPACE_VERSION
43 #define __glibcxx_signed(_Tp) ((_Tp)(-1) < 0) 44 #define __glibcxx_digits(_Tp) \ 45 (sizeof(_Tp) * __CHAR_BIT__ - __glibcxx_signed(_Tp)) 47 #define __glibcxx_min(_Tp) \ 48 (__glibcxx_signed(_Tp) ? (_Tp)1 << __glibcxx_digits(_Tp) : (_Tp)0) 50 #define __glibcxx_max(_Tp) \ 51 (__glibcxx_signed(_Tp) ? \ 52 (((((_Tp)1 << (__glibcxx_digits(_Tp) - 1)) - 1) << 1) + 1) : ~(_Tp)0) 54 template<
typename _Value>
55 struct __numeric_traits_integer
58 static const _Value __min = __glibcxx_min(_Value);
59 static const _Value __max = __glibcxx_max(_Value);
63 static const bool __is_signed = __glibcxx_signed(_Value);
64 static const int __digits = __glibcxx_digits(_Value);
67 template<
typename _Value>
68 const _Value __numeric_traits_integer<_Value>::__min;
70 template<
typename _Value>
71 const _Value __numeric_traits_integer<_Value>::__max;
73 template<
typename _Value>
74 const bool __numeric_traits_integer<_Value>::__is_signed;
76 template<
typename _Value>
77 const int __numeric_traits_integer<_Value>::__digits;
79 #undef __glibcxx_signed 80 #undef __glibcxx_digits 84 #define __glibcxx_floating(_Tp, _Fval, _Dval, _LDval) \ 85 (std::__are_same<_Tp, float>::__value ? _Fval \ 86 : std::__are_same<_Tp, double>::__value ? _Dval : _LDval) 88 #define __glibcxx_max_digits10(_Tp) \ 89 (2 + __glibcxx_floating(_Tp, __FLT_MANT_DIG__, __DBL_MANT_DIG__, \ 90 __LDBL_MANT_DIG__) * 643L / 2136) 92 #define __glibcxx_digits10(_Tp) \ 93 __glibcxx_floating(_Tp, __FLT_DIG__, __DBL_DIG__, __LDBL_DIG__) 95 #define __glibcxx_max_exponent10(_Tp) \ 96 __glibcxx_floating(_Tp, __FLT_MAX_10_EXP__, __DBL_MAX_10_EXP__, \ 99 template<
typename _Value>
100 struct __numeric_traits_floating
103 static const int __max_digits10 = __glibcxx_max_digits10(_Value);
106 static const bool __is_signed =
true;
107 static const int __digits10 = __glibcxx_digits10(_Value);
108 static const int __max_exponent10 = __glibcxx_max_exponent10(_Value);
111 template<
typename _Value>
112 const int __numeric_traits_floating<_Value>::__max_digits10;
114 template<
typename _Value>
115 const bool __numeric_traits_floating<_Value>::__is_signed;
117 template<
typename _Value>
118 const int __numeric_traits_floating<_Value>::__digits10;
120 template<
typename _Value>
121 const int __numeric_traits_floating<_Value>::__max_exponent10;
123 template<
typename _Value>
124 struct __numeric_traits
125 :
public __conditional_type<std::__is_integer<_Value>::__value,
126 __numeric_traits_integer<_Value>,
127 __numeric_traits_floating<_Value> >::__type
130 _GLIBCXX_END_NAMESPACE_VERSION
133 #undef __glibcxx_floating 134 #undef __glibcxx_max_digits10 135 #undef __glibcxx_digits10 136 #undef __glibcxx_max_exponent10 GNU extensions for public use.