29 #ifndef _EXT_NUMERIC_TRAITS
30 #define _EXT_NUMERIC_TRAITS 1
32 #pragma GCC system_header
41 #define __glibcxx_signed(_Tp) ((_Tp)(-1) < 0)
42 #define __glibcxx_digits(_Tp) \
43 (sizeof(_Tp) * __CHAR_BIT__ - __glibcxx_signed(_Tp))
45 #define __glibcxx_min(_Tp) \
46 (__glibcxx_signed(_Tp) ? (_Tp)1 << __glibcxx_digits(_Tp) : (_Tp)0)
48 #define __glibcxx_max(_Tp) \
49 (__glibcxx_signed(_Tp) ? \
50 (((((_Tp)1 << (__glibcxx_digits(_Tp) - 1)) - 1) << 1) + 1) : ~(_Tp)0)
52 template<
typename _Value>
53 struct __numeric_traits_integer
56 static const _Value __min = __glibcxx_min(_Value);
57 static const _Value __max = __glibcxx_max(_Value);
61 static const bool __is_signed = __glibcxx_signed(_Value);
62 static const int __digits = __glibcxx_digits(_Value);
65 template<
typename _Value>
66 const _Value __numeric_traits_integer<_Value>::__min;
68 template<
typename _Value>
69 const _Value __numeric_traits_integer<_Value>::__max;
71 template<
typename _Value>
72 const bool __numeric_traits_integer<_Value>::__is_signed;
74 template<
typename _Value>
75 const int __numeric_traits_integer<_Value>::__digits;
77 #undef __glibcxx_signed
78 #undef __glibcxx_digits
82 #define __glibcxx_floating(_Tp, _Fval, _Dval, _LDval) \
83 (std::__are_same<_Tp, float>::__value ? _Fval \
84 : std::__are_same<_Tp, double>::__value ? _Dval : _LDval)
86 #define __glibcxx_max_digits10(_Tp) \
87 (2 + __glibcxx_floating(_Tp, __FLT_MANT_DIG__, __DBL_MANT_DIG__, \
88 __LDBL_MANT_DIG__) * 3010 / 10000)
90 #define __glibcxx_digits10(_Tp) \
91 __glibcxx_floating(_Tp, __FLT_DIG__, __DBL_DIG__, __LDBL_DIG__)
93 #define __glibcxx_max_exponent10(_Tp) \
94 __glibcxx_floating(_Tp, __FLT_MAX_10_EXP__, __DBL_MAX_10_EXP__, \
97 template<
typename _Value>
98 struct __numeric_traits_floating
101 static const int __max_digits10 = __glibcxx_max_digits10(_Value);
104 static const bool __is_signed =
true;
105 static const int __digits10 = __glibcxx_digits10(_Value);
106 static const int __max_exponent10 = __glibcxx_max_exponent10(_Value);
109 template<
typename _Value>
110 const int __numeric_traits_floating<_Value>::__max_digits10;
112 template<
typename _Value>
113 const bool __numeric_traits_floating<_Value>::__is_signed;
115 template<
typename _Value>
116 const int __numeric_traits_floating<_Value>::__digits10;
118 template<
typename _Value>
119 const int __numeric_traits_floating<_Value>::__max_exponent10;
121 template<
typename _Value>
122 struct __numeric_traits
123 :
public __conditional_type<std::__is_integer<_Value>::__value,
124 __numeric_traits_integer<_Value>,
125 __numeric_traits_floating<_Value> >::__type
128 _GLIBCXX_END_NAMESPACE
130 #undef __glibcxx_floating
131 #undef __glibcxx_max_digits10
132 #undef __glibcxx_digits10
133 #undef __glibcxx_max_exponent10
GNU extensions for public use.