1// -*- C++ -*- 2//===----------------------------------------------------------------------===// 3// 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 7// 8//===----------------------------------------------------------------------===// 9 10#ifndef _LIBCPP_LIMITS 11#define _LIBCPP_LIMITS 12 13/* 14 limits synopsis 15 16namespace std 17{ 18 19template<class T> 20class numeric_limits 21{ 22public: 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; 27 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; 37 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; 42 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; 52 53 static constexpr bool is_iec559 = false; 54 static constexpr bool is_bounded = false; 55 static constexpr bool is_modulo = false; 56 57 static constexpr bool traps = false; 58 static constexpr bool tinyness_before = false; 59 static constexpr float_round_style round_style = round_toward_zero; 60}; 61 62enum float_round_style 63{ 64 round_indeterminate = -1, 65 round_toward_zero = 0, 66 round_to_nearest = 1, 67 round_toward_infinity = 2, 68 round_toward_neg_infinity = 3 69}; 70 71enum float_denorm_style // deprecated in C++23 72{ 73 denorm_indeterminate = -1, 74 denorm_absent = 0, 75 denorm_present = 1 76}; 77 78template<> class numeric_limits<cv bool>; 79 80template<> class numeric_limits<cv char>; 81template<> class numeric_limits<cv signed char>; 82template<> class numeric_limits<cv unsigned char>; 83template<> class numeric_limits<cv wchar_t>; 84template<> class numeric_limits<cv char8_t>; // C++20 85template<> class numeric_limits<cv char16_t>; 86template<> class numeric_limits<cv char32_t>; 87 88template<> class numeric_limits<cv short>; 89template<> class numeric_limits<cv int>; 90template<> class numeric_limits<cv long>; 91template<> class numeric_limits<cv long long>; 92template<> class numeric_limits<cv unsigned short>; 93template<> class numeric_limits<cv unsigned int>; 94template<> class numeric_limits<cv unsigned long>; 95template<> class numeric_limits<cv unsigned long long>; 96 97template<> class numeric_limits<cv float>; 98template<> class numeric_limits<cv double>; 99template<> class numeric_limits<cv long double>; 100 101} // std 102 103*/ 104 105#include <__config> 106#include <__type_traits/is_arithmetic.h> 107#include <__type_traits/is_signed.h> 108#include <__type_traits/remove_cv.h> 109 110#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 111# pragma GCC system_header 112#endif 113 114_LIBCPP_PUSH_MACROS 115#include <__undef_macros> 116#include <version> 117 118_LIBCPP_BEGIN_NAMESPACE_STD 119 120enum 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 126}; 127 128enum _LIBCPP_DEPRECATED_IN_CXX23 float_denorm_style { 129 denorm_indeterminate = -1, 130 denorm_absent = 0, 131 denorm_present = 1 132}; 133 134template <class _Tp, bool = is_arithmetic<_Tp>::value> 135class __libcpp_numeric_limits { 136protected: 137 typedef _Tp type; 138 139 static _LIBCPP_CONSTEXPR const bool is_specialized = false; 140 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return type(); } 141 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return type(); } 142 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return type(); } 143 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 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(); } 152 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(); } 153 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; 158 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 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(); } 165 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(); } 166 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(); } 167 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(); } 168 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; 172 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; 176}; 177 178template <class _Tp, int __digits, bool _IsSigned> 179struct __libcpp_compute_min { 180 static _LIBCPP_CONSTEXPR const _Tp value = _Tp(_Tp(1) << __digits); 181}; 182 183template <class _Tp, int __digits> 184struct __libcpp_compute_min<_Tp, __digits, false> { 185 static _LIBCPP_CONSTEXPR const _Tp value = _Tp(0); 186}; 187 188template <class _Tp> 189class __libcpp_numeric_limits<_Tp, true> { 190protected: 191 typedef _Tp type; 192 193 static _LIBCPP_CONSTEXPR const bool is_specialized = true; 194 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 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __min; } 202 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __max; } 203 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return min(); } 204 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 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(0); } 209 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(0); } 210 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; 215 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 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(0); } 222 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(0); } 223 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(0); } 224 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(0); } 225 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; 229 230#if defined(__i386__) || defined(__x86_64__) || defined(__pnacl__) || defined(__wasm__) 231 static _LIBCPP_CONSTEXPR const bool traps = true; 232#else 233 static _LIBCPP_CONSTEXPR const bool traps = false; 234#endif 235 static _LIBCPP_CONSTEXPR const bool tinyness_before = false; 236 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_toward_zero; 237}; 238 239template <> 240class __libcpp_numeric_limits<bool, true> { 241protected: 242 typedef bool type; 243 244 static _LIBCPP_CONSTEXPR const bool is_specialized = true; 245 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 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __min; } 253 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __max; } 254 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return min(); } 255 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 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(0); } 260 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(0); } 261 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; 266 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 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(0); } 273 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(0); } 274 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(0); } 275 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(0); } 276 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; 280 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; 284}; 285 286template <> 287class __libcpp_numeric_limits<float, true> { 288protected: 289 typedef float type; 290 291 static _LIBCPP_CONSTEXPR const bool is_specialized = true; 292 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 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __FLT_MIN__; } 298 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __FLT_MAX__; } 299 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); } 300 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 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __FLT_EPSILON__; } 305 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5F; } 306 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__; 311 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 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return __builtin_huge_valf(); } 318 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return __builtin_nanf(""); } 319 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return __builtin_nansf(""); } 320 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return __FLT_DENORM_MIN__; } 321 322 static _LIBCPP_CONSTEXPR const bool is_iec559 = true; 323 static _LIBCPP_CONSTEXPR const bool is_bounded = true; 324 static _LIBCPP_CONSTEXPR const bool is_modulo = false; 325 326 static _LIBCPP_CONSTEXPR const bool traps = false; 327#if (defined(__arm__) || defined(__aarch64__)) 328 static _LIBCPP_CONSTEXPR const bool tinyness_before = true; 329#else 330 static _LIBCPP_CONSTEXPR const bool tinyness_before = false; 331#endif 332 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest; 333}; 334 335template <> 336class __libcpp_numeric_limits<double, true> { 337protected: 338 typedef double type; 339 340 static _LIBCPP_CONSTEXPR const bool is_specialized = true; 341 342 static _LIBCPP_CONSTEXPR const bool is_signed = true; 343 static _LIBCPP_CONSTEXPR const int digits = __DBL_MANT_DIG__; 344 static _LIBCPP_CONSTEXPR const int digits10 = __DBL_DIG__; 345 static _LIBCPP_CONSTEXPR const int max_digits10 = 2 + (digits * 30103l) / 100000l; 346 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __DBL_MIN__; } 347 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __DBL_MAX__; } 348 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); } 349 350 static _LIBCPP_CONSTEXPR const bool is_integer = false; 351 static _LIBCPP_CONSTEXPR const bool is_exact = false; 352 static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__; 353 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __DBL_EPSILON__; } 354 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5; } 355 356 static _LIBCPP_CONSTEXPR const int min_exponent = __DBL_MIN_EXP__; 357 static _LIBCPP_CONSTEXPR const int min_exponent10 = __DBL_MIN_10_EXP__; 358 static _LIBCPP_CONSTEXPR const int max_exponent = __DBL_MAX_EXP__; 359 static _LIBCPP_CONSTEXPR const int max_exponent10 = __DBL_MAX_10_EXP__; 360 361 static _LIBCPP_CONSTEXPR const bool has_infinity = true; 362 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = true; 363 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true; 364 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present; 365 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false; 366 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return __builtin_huge_val(); } 367 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return __builtin_nan(""); } 368 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return __builtin_nans(""); } 369 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return __DBL_DENORM_MIN__; } 370 371 static _LIBCPP_CONSTEXPR const bool is_iec559 = true; 372 static _LIBCPP_CONSTEXPR const bool is_bounded = true; 373 static _LIBCPP_CONSTEXPR const bool is_modulo = false; 374 375 static _LIBCPP_CONSTEXPR const bool traps = false; 376#if (defined(__arm__) || defined(__aarch64__)) 377 static _LIBCPP_CONSTEXPR const bool tinyness_before = true; 378#else 379 static _LIBCPP_CONSTEXPR const bool tinyness_before = false; 380#endif 381 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest; 382}; 383 384template <> 385class __libcpp_numeric_limits<long double, true> { 386protected: 387 typedef long double type; 388 389 static _LIBCPP_CONSTEXPR const bool is_specialized = true; 390 391 static _LIBCPP_CONSTEXPR const bool is_signed = true; 392 static _LIBCPP_CONSTEXPR const int digits = __LDBL_MANT_DIG__; 393 static _LIBCPP_CONSTEXPR const int digits10 = __LDBL_DIG__; 394 static _LIBCPP_CONSTEXPR const int max_digits10 = 2 + (digits * 30103l) / 100000l; 395 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __LDBL_MIN__; } 396 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __LDBL_MAX__; } 397 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); } 398 399 static _LIBCPP_CONSTEXPR const bool is_integer = false; 400 static _LIBCPP_CONSTEXPR const bool is_exact = false; 401 static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__; 402 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __LDBL_EPSILON__; } 403 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5L; } 404 405 static _LIBCPP_CONSTEXPR const int min_exponent = __LDBL_MIN_EXP__; 406 static _LIBCPP_CONSTEXPR const int min_exponent10 = __LDBL_MIN_10_EXP__; 407 static _LIBCPP_CONSTEXPR const int max_exponent = __LDBL_MAX_EXP__; 408 static _LIBCPP_CONSTEXPR const int max_exponent10 = __LDBL_MAX_10_EXP__; 409 410 static _LIBCPP_CONSTEXPR const bool has_infinity = true; 411 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = true; 412 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true; 413 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present; 414 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false; 415 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return __builtin_huge_vall(); } 416 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return __builtin_nanl(""); } 417 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return __builtin_nansl(""); } 418 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return __LDBL_DENORM_MIN__; } 419 420#if defined(__powerpc__) && defined(__LONG_DOUBLE_IBM128__) 421 static _LIBCPP_CONSTEXPR const bool is_iec559 = false; 422#else 423 static _LIBCPP_CONSTEXPR const bool is_iec559 = true; 424#endif 425 static _LIBCPP_CONSTEXPR const bool is_bounded = true; 426 static _LIBCPP_CONSTEXPR const bool is_modulo = false; 427 428 static _LIBCPP_CONSTEXPR const bool traps = false; 429#if (defined(__arm__) || defined(__aarch64__)) 430 static _LIBCPP_CONSTEXPR const bool tinyness_before = true; 431#else 432 static _LIBCPP_CONSTEXPR const bool tinyness_before = false; 433#endif 434 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest; 435}; 436 437template <class _Tp> 438class _LIBCPP_TEMPLATE_VIS numeric_limits : private __libcpp_numeric_limits<_Tp> { 439 typedef __libcpp_numeric_limits<_Tp> __base; 440 typedef typename __base::type type; 441 442public: 443 static _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized; 444 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __base::min(); } 445 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __base::max(); } 446 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return __base::lowest(); } 447 448 static _LIBCPP_CONSTEXPR const int digits = __base::digits; 449 static _LIBCPP_CONSTEXPR const int digits10 = __base::digits10; 450 static _LIBCPP_CONSTEXPR const int max_digits10 = __base::max_digits10; 451 static _LIBCPP_CONSTEXPR const bool is_signed = __base::is_signed; 452 static _LIBCPP_CONSTEXPR const bool is_integer = __base::is_integer; 453 static _LIBCPP_CONSTEXPR const bool is_exact = __base::is_exact; 454 static _LIBCPP_CONSTEXPR const int radix = __base::radix; 455 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __base::epsilon(); } 456 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return __base::round_error(); } 457 458 static _LIBCPP_CONSTEXPR const int min_exponent = __base::min_exponent; 459 static _LIBCPP_CONSTEXPR const int min_exponent10 = __base::min_exponent10; 460 static _LIBCPP_CONSTEXPR const int max_exponent = __base::max_exponent; 461 static _LIBCPP_CONSTEXPR const int max_exponent10 = __base::max_exponent10; 462 463 static _LIBCPP_CONSTEXPR const bool has_infinity = __base::has_infinity; 464 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = __base::has_quiet_NaN; 465 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN; 466 _LIBCPP_SUPPRESS_DEPRECATED_PUSH 467 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm; 468 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss; 469 _LIBCPP_SUPPRESS_DEPRECATED_POP 470 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return __base::infinity(); } 471 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return __base::quiet_NaN(); } 472 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return __base::signaling_NaN(); } 473 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return __base::denorm_min(); } 474 475 static _LIBCPP_CONSTEXPR const bool is_iec559 = __base::is_iec559; 476 static _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded; 477 static _LIBCPP_CONSTEXPR const bool is_modulo = __base::is_modulo; 478 479 static _LIBCPP_CONSTEXPR const bool traps = __base::traps; 480 static _LIBCPP_CONSTEXPR const bool tinyness_before = __base::tinyness_before; 481 static _LIBCPP_CONSTEXPR const float_round_style round_style = __base::round_style; 482}; 483 484template <class _Tp> 485_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_specialized; 486template <class _Tp> 487_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::digits; 488template <class _Tp> 489_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::digits10; 490template <class _Tp> 491_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::max_digits10; 492template <class _Tp> 493_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_signed; 494template <class _Tp> 495_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_integer; 496template <class _Tp> 497_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_exact; 498template <class _Tp> 499_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::radix; 500template <class _Tp> 501_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::min_exponent; 502template <class _Tp> 503_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::min_exponent10; 504template <class _Tp> 505_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::max_exponent; 506template <class _Tp> 507_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::max_exponent10; 508template <class _Tp> 509_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_infinity; 510template <class _Tp> 511_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_quiet_NaN; 512template <class _Tp> 513_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_signaling_NaN; 514template <class _Tp> 515_LIBCPP_CONSTEXPR const float_denorm_style numeric_limits<_Tp>::has_denorm; 516template <class _Tp> 517_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_denorm_loss; 518template <class _Tp> 519_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_iec559; 520template <class _Tp> 521_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_bounded; 522template <class _Tp> 523_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_modulo; 524template <class _Tp> 525_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::traps; 526template <class _Tp> 527_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::tinyness_before; 528template <class _Tp> 529_LIBCPP_CONSTEXPR const float_round_style numeric_limits<_Tp>::round_style; 530 531template <class _Tp> 532class _LIBCPP_TEMPLATE_VIS numeric_limits<const _Tp> : public numeric_limits<_Tp> {}; 533 534template <class _Tp> 535class _LIBCPP_TEMPLATE_VIS numeric_limits<volatile _Tp> : public numeric_limits<_Tp> {}; 536 537template <class _Tp> 538class _LIBCPP_TEMPLATE_VIS numeric_limits<const volatile _Tp> : public numeric_limits<_Tp> {}; 539 540_LIBCPP_END_NAMESPACE_STD 541 542_LIBCPP_POP_MACROS 543 544#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 545# include <type_traits> 546#endif 547 548#endif // _LIBCPP_LIMITS 549