2 //===----------------------------------------------------------------------===//
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP_LIMITS
11 #define _LIBCPP_LIMITS
23 static constexpr bool is_specialized = false;
24 static constexpr T min() noexcept;
25 static constexpr T max() noexcept;
26 static constexpr T lowest() noexcept;
28 static constexpr int digits = 0;
29 static constexpr int digits10 = 0;
30 static constexpr int max_digits10 = 0;
31 static constexpr bool is_signed = false;
32 static constexpr bool is_integer = false;
33 static constexpr bool is_exact = false;
34 static constexpr int radix = 0;
35 static constexpr T epsilon() noexcept;
36 static constexpr T round_error() noexcept;
38 static constexpr int min_exponent = 0;
39 static constexpr int min_exponent10 = 0;
40 static constexpr int max_exponent = 0;
41 static constexpr int max_exponent10 = 0;
43 static constexpr bool has_infinity = false;
44 static constexpr bool has_quiet_NaN = false;
45 static constexpr bool has_signaling_NaN = false;
46 static constexpr float_denorm_style has_denorm = denorm_absent; // deprecated in C++23
47 static constexpr bool has_denorm_loss = false; // deprecated in C++23
48 static constexpr T infinity() noexcept;
49 static constexpr T quiet_NaN() noexcept;
50 static constexpr T signaling_NaN() noexcept;
51 static constexpr T denorm_min() noexcept;
53 static constexpr bool is_iec559 = false;
54 static constexpr bool is_bounded = false;
55 static constexpr bool is_modulo = false;
57 static constexpr bool traps = false;
58 static constexpr bool tinyness_before = false;
59 static constexpr float_round_style round_style = round_toward_zero;
62 enum float_round_style
64 round_indeterminate = -1,
65 round_toward_zero = 0,
67 round_toward_infinity = 2,
68 round_toward_neg_infinity = 3
71 enum float_denorm_style // deprecated in C++23
73 denorm_indeterminate = -1,
78 template<> class numeric_limits<cv bool>;
80 template<> class numeric_limits<cv char>;
81 template<> class numeric_limits<cv signed char>;
82 template<> class numeric_limits<cv unsigned char>;
83 template<> class numeric_limits<cv wchar_t>;
84 template<> class numeric_limits<cv char8_t>; // C++20
85 template<> class numeric_limits<cv char16_t>;
86 template<> class numeric_limits<cv char32_t>;
88 template<> class numeric_limits<cv short>;
89 template<> class numeric_limits<cv int>;
90 template<> class numeric_limits<cv long>;
91 template<> class numeric_limits<cv long long>;
92 template<> class numeric_limits<cv unsigned short>;
93 template<> class numeric_limits<cv unsigned int>;
94 template<> class numeric_limits<cv unsigned long>;
95 template<> class numeric_limits<cv unsigned long long>;
97 template<> class numeric_limits<cv float>;
98 template<> class numeric_limits<cv double>;
99 template<> class numeric_limits<cv long double>;
106 #include <__type_traits/is_arithmetic.h>
107 #include <__type_traits/is_signed.h>
108 #include <__type_traits/remove_cv.h>
110 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
111 # pragma GCC system_header
115 #include <__undef_macros>
118 _LIBCPP_BEGIN_NAMESPACE_STD
120 enum float_round_style {
121 round_indeterminate = -1,
122 round_toward_zero = 0,
123 round_to_nearest = 1,
124 round_toward_infinity = 2,
125 round_toward_neg_infinity = 3
128 enum _LIBCPP_DEPRECATED_IN_CXX23 float_denorm_style {
129 denorm_indeterminate = -1,
134 template <class _Tp, bool = is_arithmetic<_Tp>::value>
135 class __libcpp_numeric_limits {
139 static _LIBCPP_CONSTEXPR const bool is_specialized = false;
140 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return type(); }
141 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return type(); }
142 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return type(); }
144 static _LIBCPP_CONSTEXPR const int digits = 0;
145 static _LIBCPP_CONSTEXPR const int digits10 = 0;
146 static _LIBCPP_CONSTEXPR const int max_digits10 = 0;
147 static _LIBCPP_CONSTEXPR const bool is_signed = false;
148 static _LIBCPP_CONSTEXPR const bool is_integer = false;
149 static _LIBCPP_CONSTEXPR const bool is_exact = false;
150 static _LIBCPP_CONSTEXPR const int radix = 0;
151 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(); }
152 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(); }
154 static _LIBCPP_CONSTEXPR const int min_exponent = 0;
155 static _LIBCPP_CONSTEXPR const int min_exponent10 = 0;
156 static _LIBCPP_CONSTEXPR const int max_exponent = 0;
157 static _LIBCPP_CONSTEXPR const int max_exponent10 = 0;
159 static _LIBCPP_CONSTEXPR const bool has_infinity = false;
160 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = false;
161 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false;
162 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent;
163 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
164 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(); }
165 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(); }
166 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(); }
167 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(); }
169 static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
170 static _LIBCPP_CONSTEXPR const bool is_bounded = false;
171 static _LIBCPP_CONSTEXPR const bool is_modulo = false;
173 static _LIBCPP_CONSTEXPR const bool traps = false;
174 static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
175 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_toward_zero;
178 template <class _Tp, int __digits, bool _IsSigned>
179 struct __libcpp_compute_min {
180 static _LIBCPP_CONSTEXPR const _Tp value = _Tp(_Tp(1) << __digits);
183 template <class _Tp, int __digits>
184 struct __libcpp_compute_min<_Tp, __digits, false> {
185 static _LIBCPP_CONSTEXPR const _Tp value = _Tp(0);
189 class __libcpp_numeric_limits<_Tp, true> {
193 static _LIBCPP_CONSTEXPR const bool is_specialized = true;
195 static _LIBCPP_CONSTEXPR const bool is_signed = type(-1) < type(0);
196 static _LIBCPP_CONSTEXPR const int digits = static_cast<int>(sizeof(type) * __CHAR_BIT__ - is_signed);
197 static _LIBCPP_CONSTEXPR const int digits10 = digits * 3 / 10;
198 static _LIBCPP_CONSTEXPR const int max_digits10 = 0;
199 static _LIBCPP_CONSTEXPR const type __min = __libcpp_compute_min<type, digits, is_signed>::value;
200 static _LIBCPP_CONSTEXPR const type __max = is_signed ? type(type(~0) ^ __min) : type(~0);
201 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __min; }
202 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __max; }
203 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return min(); }
205 static _LIBCPP_CONSTEXPR const bool is_integer = true;
206 static _LIBCPP_CONSTEXPR const bool is_exact = true;
207 static _LIBCPP_CONSTEXPR const int radix = 2;
208 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(0); }
209 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(0); }
211 static _LIBCPP_CONSTEXPR const int min_exponent = 0;
212 static _LIBCPP_CONSTEXPR const int min_exponent10 = 0;
213 static _LIBCPP_CONSTEXPR const int max_exponent = 0;
214 static _LIBCPP_CONSTEXPR const int max_exponent10 = 0;
216 static _LIBCPP_CONSTEXPR const bool has_infinity = false;
217 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = false;
218 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false;
219 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent;
220 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
221 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(0); }
222 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(0); }
223 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(0); }
224 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(0); }
226 static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
227 static _LIBCPP_CONSTEXPR const bool is_bounded = true;
228 static _LIBCPP_CONSTEXPR const bool is_modulo = !std::is_signed<_Tp>::value;
230 #if defined(__i386__) || defined(__x86_64__) || defined(__pnacl__) || defined(__wasm__)
231 static _LIBCPP_CONSTEXPR const bool traps = true;
233 static _LIBCPP_CONSTEXPR const bool traps = false;
235 static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
236 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_toward_zero;
240 class __libcpp_numeric_limits<bool, true> {
244 static _LIBCPP_CONSTEXPR const bool is_specialized = true;
246 static _LIBCPP_CONSTEXPR const bool is_signed = false;
247 static _LIBCPP_CONSTEXPR const int digits = 1;
248 static _LIBCPP_CONSTEXPR const int digits10 = 0;
249 static _LIBCPP_CONSTEXPR const int max_digits10 = 0;
250 static _LIBCPP_CONSTEXPR const type __min = false;
251 static _LIBCPP_CONSTEXPR const type __max = true;
252 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __min; }
253 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __max; }
254 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return min(); }
256 static _LIBCPP_CONSTEXPR const bool is_integer = true;
257 static _LIBCPP_CONSTEXPR const bool is_exact = true;
258 static _LIBCPP_CONSTEXPR const int radix = 2;
259 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(0); }
260 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(0); }
262 static _LIBCPP_CONSTEXPR const int min_exponent = 0;
263 static _LIBCPP_CONSTEXPR const int min_exponent10 = 0;
264 static _LIBCPP_CONSTEXPR const int max_exponent = 0;
265 static _LIBCPP_CONSTEXPR const int max_exponent10 = 0;
267 static _LIBCPP_CONSTEXPR const bool has_infinity = false;
268 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = false;
269 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false;
270 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent;
271 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
272 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(0); }
273 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(0); }
274 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(0); }
275 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(0); }
277 static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
278 static _LIBCPP_CONSTEXPR const bool is_bounded = true;
279 static _LIBCPP_CONSTEXPR const bool is_modulo = false;
281 static _LIBCPP_CONSTEXPR const bool traps = false;
282 static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
283 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_toward_zero;
287 class __libcpp_numeric_limits<float, true> {
291 static _LIBCPP_CONSTEXPR const bool is_specialized = true;
293 static _LIBCPP_CONSTEXPR const bool is_signed = true;
294 static _LIBCPP_CONSTEXPR const int digits = __FLT_MANT_DIG__;
295 static _LIBCPP_CONSTEXPR const int digits10 = __FLT_DIG__;
296 static _LIBCPP_CONSTEXPR const int max_digits10 = 2 + (digits * 30103l) / 100000l;
297 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __FLT_MIN__; }
298 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __FLT_MAX__; }
299 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); }
301 static _LIBCPP_CONSTEXPR const bool is_integer = false;
302 static _LIBCPP_CONSTEXPR const bool is_exact = false;
303 static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__;
304 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __FLT_EPSILON__; }
305 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5F; }
307 static _LIBCPP_CONSTEXPR const int min_exponent = __FLT_MIN_EXP__;
308 static _LIBCPP_CONSTEXPR const int min_exponent10 = __FLT_MIN_10_EXP__;
309 static _LIBCPP_CONSTEXPR const int max_exponent = __FLT_MAX_EXP__;
310 static _LIBCPP_CONSTEXPR const int max_exponent10 = __FLT_MAX_10_EXP__;
312 static _LIBCPP_CONSTEXPR const bool has_infinity = true;
313 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = true;
314 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true;
315 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present;
316 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
317 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {
318 return __builtin_huge_valf();
320 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {
321 return __builtin_nanf("");
323 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {
324 return __builtin_nansf("");
326 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {
327 return __FLT_DENORM_MIN__;
330 static _LIBCPP_CONSTEXPR const bool is_iec559 = true;
331 static _LIBCPP_CONSTEXPR const bool is_bounded = true;
332 static _LIBCPP_CONSTEXPR const bool is_modulo = false;
334 static _LIBCPP_CONSTEXPR const bool traps = false;
335 #if (defined(__arm__) || defined(__aarch64__))
336 static _LIBCPP_CONSTEXPR const bool tinyness_before = true;
338 static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
340 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest;
344 class __libcpp_numeric_limits<double, true> {
348 static _LIBCPP_CONSTEXPR const bool is_specialized = true;
350 static _LIBCPP_CONSTEXPR const bool is_signed = true;
351 static _LIBCPP_CONSTEXPR const int digits = __DBL_MANT_DIG__;
352 static _LIBCPP_CONSTEXPR const int digits10 = __DBL_DIG__;
353 static _LIBCPP_CONSTEXPR const int max_digits10 = 2 + (digits * 30103l) / 100000l;
354 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __DBL_MIN__; }
355 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __DBL_MAX__; }
356 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); }
358 static _LIBCPP_CONSTEXPR const bool is_integer = false;
359 static _LIBCPP_CONSTEXPR const bool is_exact = false;
360 static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__;
361 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __DBL_EPSILON__; }
362 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5; }
364 static _LIBCPP_CONSTEXPR const int min_exponent = __DBL_MIN_EXP__;
365 static _LIBCPP_CONSTEXPR const int min_exponent10 = __DBL_MIN_10_EXP__;
366 static _LIBCPP_CONSTEXPR const int max_exponent = __DBL_MAX_EXP__;
367 static _LIBCPP_CONSTEXPR const int max_exponent10 = __DBL_MAX_10_EXP__;
369 static _LIBCPP_CONSTEXPR const bool has_infinity = true;
370 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = true;
371 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true;
372 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present;
373 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
374 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {
375 return __builtin_huge_val();
377 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {
378 return __builtin_nan("");
380 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {
381 return __builtin_nans("");
383 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {
384 return __DBL_DENORM_MIN__;
387 static _LIBCPP_CONSTEXPR const bool is_iec559 = true;
388 static _LIBCPP_CONSTEXPR const bool is_bounded = true;
389 static _LIBCPP_CONSTEXPR const bool is_modulo = false;
391 static _LIBCPP_CONSTEXPR const bool traps = false;
392 #if (defined(__arm__) || defined(__aarch64__))
393 static _LIBCPP_CONSTEXPR const bool tinyness_before = true;
395 static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
397 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest;
401 class __libcpp_numeric_limits<long double, true> {
403 typedef long double type;
405 static _LIBCPP_CONSTEXPR const bool is_specialized = true;
407 static _LIBCPP_CONSTEXPR const bool is_signed = true;
408 static _LIBCPP_CONSTEXPR const int digits = __LDBL_MANT_DIG__;
409 static _LIBCPP_CONSTEXPR const int digits10 = __LDBL_DIG__;
410 static _LIBCPP_CONSTEXPR const int max_digits10 = 2 + (digits * 30103l) / 100000l;
411 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __LDBL_MIN__; }
412 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __LDBL_MAX__; }
413 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); }
415 static _LIBCPP_CONSTEXPR const bool is_integer = false;
416 static _LIBCPP_CONSTEXPR const bool is_exact = false;
417 static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__;
418 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __LDBL_EPSILON__; }
419 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5L; }
421 static _LIBCPP_CONSTEXPR const int min_exponent = __LDBL_MIN_EXP__;
422 static _LIBCPP_CONSTEXPR const int min_exponent10 = __LDBL_MIN_10_EXP__;
423 static _LIBCPP_CONSTEXPR const int max_exponent = __LDBL_MAX_EXP__;
424 static _LIBCPP_CONSTEXPR const int max_exponent10 = __LDBL_MAX_10_EXP__;
426 static _LIBCPP_CONSTEXPR const bool has_infinity = true;
427 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = true;
428 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true;
429 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present;
430 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
431 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {
432 return __builtin_huge_vall();
434 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {
435 return __builtin_nanl("");
437 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {
438 return __builtin_nansl("");
440 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {
441 return __LDBL_DENORM_MIN__;
444 #if defined(__powerpc__) && defined(__LONG_DOUBLE_IBM128__)
445 static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
447 static _LIBCPP_CONSTEXPR const bool is_iec559 = true;
449 static _LIBCPP_CONSTEXPR const bool is_bounded = true;
450 static _LIBCPP_CONSTEXPR const bool is_modulo = false;
452 static _LIBCPP_CONSTEXPR const bool traps = false;
453 #if (defined(__arm__) || defined(__aarch64__))
454 static _LIBCPP_CONSTEXPR const bool tinyness_before = true;
456 static _LIBCPP_CONSTEXPR const bool tinyness_before = false;
458 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest;
462 class _LIBCPP_TEMPLATE_VIS numeric_limits : private __libcpp_numeric_limits<_Tp> {
463 typedef __libcpp_numeric_limits<_Tp> __base;
464 typedef typename __base::type type;
467 static inline _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized;
468 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __base::min(); }
469 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __base::max(); }
470 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return __base::lowest(); }
472 static inline _LIBCPP_CONSTEXPR const int digits = __base::digits;
473 static inline _LIBCPP_CONSTEXPR const int digits10 = __base::digits10;
474 static inline _LIBCPP_CONSTEXPR const int max_digits10 = __base::max_digits10;
475 static inline _LIBCPP_CONSTEXPR const bool is_signed = __base::is_signed;
476 static inline _LIBCPP_CONSTEXPR const bool is_integer = __base::is_integer;
477 static inline _LIBCPP_CONSTEXPR const bool is_exact = __base::is_exact;
478 static inline _LIBCPP_CONSTEXPR const int radix = __base::radix;
479 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {
480 return __base::epsilon();
482 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {
483 return __base::round_error();
486 static inline _LIBCPP_CONSTEXPR const int min_exponent = __base::min_exponent;
487 static inline _LIBCPP_CONSTEXPR const int min_exponent10 = __base::min_exponent10;
488 static inline _LIBCPP_CONSTEXPR const int max_exponent = __base::max_exponent;
489 static inline _LIBCPP_CONSTEXPR const int max_exponent10 = __base::max_exponent10;
491 static inline _LIBCPP_CONSTEXPR const bool has_infinity = __base::has_infinity;
492 static inline _LIBCPP_CONSTEXPR const bool has_quiet_NaN = __base::has_quiet_NaN;
493 static inline _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN;
494 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
495 static inline _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm;
496 static inline _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss;
497 _LIBCPP_SUPPRESS_DEPRECATED_POP
498 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {
499 return __base::infinity();
501 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {
502 return __base::quiet_NaN();
504 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {
505 return __base::signaling_NaN();
507 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {
508 return __base::denorm_min();
511 static inline _LIBCPP_CONSTEXPR const bool is_iec559 = __base::is_iec559;
512 static inline _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded;
513 static inline _LIBCPP_CONSTEXPR const bool is_modulo = __base::is_modulo;
515 static inline _LIBCPP_CONSTEXPR const bool traps = __base::traps;
516 static inline _LIBCPP_CONSTEXPR const bool tinyness_before = __base::tinyness_before;
517 static inline _LIBCPP_CONSTEXPR const float_round_style round_style = __base::round_style;
521 class _LIBCPP_TEMPLATE_VIS numeric_limits<const _Tp> : public numeric_limits<_Tp> {};
524 class _LIBCPP_TEMPLATE_VIS numeric_limits<volatile _Tp> : public numeric_limits<_Tp> {};
527 class _LIBCPP_TEMPLATE_VIS numeric_limits<const volatile _Tp> : public numeric_limits<_Tp> {};
529 _LIBCPP_END_NAMESPACE_STD
533 #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
534 # include <type_traits>
537 #endif // _LIBCPP_LIMITS