1*700637cbSDimitry Andric// -*- C++ -*- 2*700637cbSDimitry Andric//===----------------------------------------------------------------------===// 3*700637cbSDimitry Andric// 4*700637cbSDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5*700637cbSDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 6*700637cbSDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7*700637cbSDimitry Andric// 8*700637cbSDimitry Andric//===----------------------------------------------------------------------===// 9*700637cbSDimitry Andric 10*700637cbSDimitry Andric#ifndef _LIBCPP___CXX03_LIMITS 11*700637cbSDimitry Andric#define _LIBCPP___CXX03_LIMITS 12*700637cbSDimitry Andric 13*700637cbSDimitry Andric/* 14*700637cbSDimitry Andric limits synopsis 15*700637cbSDimitry Andric 16*700637cbSDimitry Andricnamespace std 17*700637cbSDimitry Andric{ 18*700637cbSDimitry Andric 19*700637cbSDimitry Andrictemplate<class T> 20*700637cbSDimitry Andricclass numeric_limits 21*700637cbSDimitry Andric{ 22*700637cbSDimitry Andricpublic: 23*700637cbSDimitry Andric static constexpr bool is_specialized = false; 24*700637cbSDimitry Andric static constexpr T min() noexcept; 25*700637cbSDimitry Andric static constexpr T max() noexcept; 26*700637cbSDimitry Andric static constexpr T lowest() noexcept; 27*700637cbSDimitry Andric 28*700637cbSDimitry Andric static constexpr int digits = 0; 29*700637cbSDimitry Andric static constexpr int digits10 = 0; 30*700637cbSDimitry Andric static constexpr int max_digits10 = 0; 31*700637cbSDimitry Andric static constexpr bool is_signed = false; 32*700637cbSDimitry Andric static constexpr bool is_integer = false; 33*700637cbSDimitry Andric static constexpr bool is_exact = false; 34*700637cbSDimitry Andric static constexpr int radix = 0; 35*700637cbSDimitry Andric static constexpr T epsilon() noexcept; 36*700637cbSDimitry Andric static constexpr T round_error() noexcept; 37*700637cbSDimitry Andric 38*700637cbSDimitry Andric static constexpr int min_exponent = 0; 39*700637cbSDimitry Andric static constexpr int min_exponent10 = 0; 40*700637cbSDimitry Andric static constexpr int max_exponent = 0; 41*700637cbSDimitry Andric static constexpr int max_exponent10 = 0; 42*700637cbSDimitry Andric 43*700637cbSDimitry Andric static constexpr bool has_infinity = false; 44*700637cbSDimitry Andric static constexpr bool has_quiet_NaN = false; 45*700637cbSDimitry Andric static constexpr bool has_signaling_NaN = false; 46*700637cbSDimitry Andric static constexpr float_denorm_style has_denorm = denorm_absent; // deprecated in C++23 47*700637cbSDimitry Andric static constexpr bool has_denorm_loss = false; // deprecated in C++23 48*700637cbSDimitry Andric static constexpr T infinity() noexcept; 49*700637cbSDimitry Andric static constexpr T quiet_NaN() noexcept; 50*700637cbSDimitry Andric static constexpr T signaling_NaN() noexcept; 51*700637cbSDimitry Andric static constexpr T denorm_min() noexcept; 52*700637cbSDimitry Andric 53*700637cbSDimitry Andric static constexpr bool is_iec559 = false; 54*700637cbSDimitry Andric static constexpr bool is_bounded = false; 55*700637cbSDimitry Andric static constexpr bool is_modulo = false; 56*700637cbSDimitry Andric 57*700637cbSDimitry Andric static constexpr bool traps = false; 58*700637cbSDimitry Andric static constexpr bool tinyness_before = false; 59*700637cbSDimitry Andric static constexpr float_round_style round_style = round_toward_zero; 60*700637cbSDimitry Andric}; 61*700637cbSDimitry Andric 62*700637cbSDimitry Andricenum float_round_style 63*700637cbSDimitry Andric{ 64*700637cbSDimitry Andric round_indeterminate = -1, 65*700637cbSDimitry Andric round_toward_zero = 0, 66*700637cbSDimitry Andric round_to_nearest = 1, 67*700637cbSDimitry Andric round_toward_infinity = 2, 68*700637cbSDimitry Andric round_toward_neg_infinity = 3 69*700637cbSDimitry Andric}; 70*700637cbSDimitry Andric 71*700637cbSDimitry Andricenum float_denorm_style // deprecated in C++23 72*700637cbSDimitry Andric{ 73*700637cbSDimitry Andric denorm_indeterminate = -1, 74*700637cbSDimitry Andric denorm_absent = 0, 75*700637cbSDimitry Andric denorm_present = 1 76*700637cbSDimitry Andric}; 77*700637cbSDimitry Andric 78*700637cbSDimitry Andrictemplate<> class numeric_limits<cv bool>; 79*700637cbSDimitry Andric 80*700637cbSDimitry Andrictemplate<> class numeric_limits<cv char>; 81*700637cbSDimitry Andrictemplate<> class numeric_limits<cv signed char>; 82*700637cbSDimitry Andrictemplate<> class numeric_limits<cv unsigned char>; 83*700637cbSDimitry Andrictemplate<> class numeric_limits<cv wchar_t>; 84*700637cbSDimitry Andrictemplate<> class numeric_limits<cv char8_t>; // C++20 85*700637cbSDimitry Andrictemplate<> class numeric_limits<cv char16_t>; 86*700637cbSDimitry Andrictemplate<> class numeric_limits<cv char32_t>; 87*700637cbSDimitry Andric 88*700637cbSDimitry Andrictemplate<> class numeric_limits<cv short>; 89*700637cbSDimitry Andrictemplate<> class numeric_limits<cv int>; 90*700637cbSDimitry Andrictemplate<> class numeric_limits<cv long>; 91*700637cbSDimitry Andrictemplate<> class numeric_limits<cv long long>; 92*700637cbSDimitry Andrictemplate<> class numeric_limits<cv unsigned short>; 93*700637cbSDimitry Andrictemplate<> class numeric_limits<cv unsigned int>; 94*700637cbSDimitry Andrictemplate<> class numeric_limits<cv unsigned long>; 95*700637cbSDimitry Andrictemplate<> class numeric_limits<cv unsigned long long>; 96*700637cbSDimitry Andric 97*700637cbSDimitry Andrictemplate<> class numeric_limits<cv float>; 98*700637cbSDimitry Andrictemplate<> class numeric_limits<cv double>; 99*700637cbSDimitry Andrictemplate<> class numeric_limits<cv long double>; 100*700637cbSDimitry Andric 101*700637cbSDimitry Andric} // std 102*700637cbSDimitry Andric 103*700637cbSDimitry Andric*/ 104*700637cbSDimitry Andric 105*700637cbSDimitry Andric#include <__cxx03/__config> 106*700637cbSDimitry Andric#include <__cxx03/__type_traits/is_arithmetic.h> 107*700637cbSDimitry Andric#include <__cxx03/__type_traits/is_signed.h> 108*700637cbSDimitry Andric#include <__cxx03/__type_traits/remove_cv.h> 109*700637cbSDimitry Andric 110*700637cbSDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 111*700637cbSDimitry Andric# pragma GCC system_header 112*700637cbSDimitry Andric#endif 113*700637cbSDimitry Andric 114*700637cbSDimitry Andric_LIBCPP_PUSH_MACROS 115*700637cbSDimitry Andric#include <__cxx03/__undef_macros> 116*700637cbSDimitry Andric#include <__cxx03/version> 117*700637cbSDimitry Andric 118*700637cbSDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD 119*700637cbSDimitry Andric 120*700637cbSDimitry Andricenum float_round_style { 121*700637cbSDimitry Andric round_indeterminate = -1, 122*700637cbSDimitry Andric round_toward_zero = 0, 123*700637cbSDimitry Andric round_to_nearest = 1, 124*700637cbSDimitry Andric round_toward_infinity = 2, 125*700637cbSDimitry Andric round_toward_neg_infinity = 3 126*700637cbSDimitry Andric}; 127*700637cbSDimitry Andric 128*700637cbSDimitry Andricenum float_denorm_style { denorm_indeterminate = -1, denorm_absent = 0, denorm_present = 1 }; 129*700637cbSDimitry Andric 130*700637cbSDimitry Andrictemplate <class _Tp, bool = is_arithmetic<_Tp>::value> 131*700637cbSDimitry Andricclass __libcpp_numeric_limits { 132*700637cbSDimitry Andricprotected: 133*700637cbSDimitry Andric typedef _Tp type; 134*700637cbSDimitry Andric 135*700637cbSDimitry Andric static const bool is_specialized = false; 136*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type min() _NOEXCEPT { return type(); } 137*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type max() _NOEXCEPT { return type(); } 138*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type lowest() _NOEXCEPT { return type(); } 139*700637cbSDimitry Andric 140*700637cbSDimitry Andric static const int digits = 0; 141*700637cbSDimitry Andric static const int digits10 = 0; 142*700637cbSDimitry Andric static const int max_digits10 = 0; 143*700637cbSDimitry Andric static const bool is_signed = false; 144*700637cbSDimitry Andric static const bool is_integer = false; 145*700637cbSDimitry Andric static const bool is_exact = false; 146*700637cbSDimitry Andric static const int radix = 0; 147*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type epsilon() _NOEXCEPT { return type(); } 148*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type round_error() _NOEXCEPT { return type(); } 149*700637cbSDimitry Andric 150*700637cbSDimitry Andric static const int min_exponent = 0; 151*700637cbSDimitry Andric static const int min_exponent10 = 0; 152*700637cbSDimitry Andric static const int max_exponent = 0; 153*700637cbSDimitry Andric static const int max_exponent10 = 0; 154*700637cbSDimitry Andric 155*700637cbSDimitry Andric static const bool has_infinity = false; 156*700637cbSDimitry Andric static const bool has_quiet_NaN = false; 157*700637cbSDimitry Andric static const bool has_signaling_NaN = false; 158*700637cbSDimitry Andric static const float_denorm_style has_denorm = denorm_absent; 159*700637cbSDimitry Andric static const bool has_denorm_loss = false; 160*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type infinity() _NOEXCEPT { return type(); } 161*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type quiet_NaN() _NOEXCEPT { return type(); } 162*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type signaling_NaN() _NOEXCEPT { return type(); } 163*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type denorm_min() _NOEXCEPT { return type(); } 164*700637cbSDimitry Andric 165*700637cbSDimitry Andric static const bool is_iec559 = false; 166*700637cbSDimitry Andric static const bool is_bounded = false; 167*700637cbSDimitry Andric static const bool is_modulo = false; 168*700637cbSDimitry Andric 169*700637cbSDimitry Andric static const bool traps = false; 170*700637cbSDimitry Andric static const bool tinyness_before = false; 171*700637cbSDimitry Andric static const float_round_style round_style = round_toward_zero; 172*700637cbSDimitry Andric}; 173*700637cbSDimitry Andric 174*700637cbSDimitry Andrictemplate <class _Tp, int __digits, bool _IsSigned> 175*700637cbSDimitry Andricstruct __libcpp_compute_min { 176*700637cbSDimitry Andric static const _Tp value = _Tp(_Tp(1) << __digits); 177*700637cbSDimitry Andric}; 178*700637cbSDimitry Andric 179*700637cbSDimitry Andrictemplate <class _Tp, int __digits> 180*700637cbSDimitry Andricstruct __libcpp_compute_min<_Tp, __digits, false> { 181*700637cbSDimitry Andric static const _Tp value = _Tp(0); 182*700637cbSDimitry Andric}; 183*700637cbSDimitry Andric 184*700637cbSDimitry Andrictemplate <class _Tp> 185*700637cbSDimitry Andricclass __libcpp_numeric_limits<_Tp, true> { 186*700637cbSDimitry Andricprotected: 187*700637cbSDimitry Andric typedef _Tp type; 188*700637cbSDimitry Andric 189*700637cbSDimitry Andric static const bool is_specialized = true; 190*700637cbSDimitry Andric 191*700637cbSDimitry Andric static const bool is_signed = type(-1) < type(0); 192*700637cbSDimitry Andric static const int digits = static_cast<int>(sizeof(type) * __CHAR_BIT__ - is_signed); 193*700637cbSDimitry Andric static const int digits10 = digits * 3 / 10; 194*700637cbSDimitry Andric static const int max_digits10 = 0; 195*700637cbSDimitry Andric static const type __min = __libcpp_compute_min<type, digits, is_signed>::value; 196*700637cbSDimitry Andric static const type __max = is_signed ? type(type(~0) ^ __min) : type(~0); 197*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type min() _NOEXCEPT { return __min; } 198*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type max() _NOEXCEPT { return __max; } 199*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type lowest() _NOEXCEPT { return min(); } 200*700637cbSDimitry Andric 201*700637cbSDimitry Andric static const bool is_integer = true; 202*700637cbSDimitry Andric static const bool is_exact = true; 203*700637cbSDimitry Andric static const int radix = 2; 204*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type epsilon() _NOEXCEPT { return type(0); } 205*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type round_error() _NOEXCEPT { return type(0); } 206*700637cbSDimitry Andric 207*700637cbSDimitry Andric static const int min_exponent = 0; 208*700637cbSDimitry Andric static const int min_exponent10 = 0; 209*700637cbSDimitry Andric static const int max_exponent = 0; 210*700637cbSDimitry Andric static const int max_exponent10 = 0; 211*700637cbSDimitry Andric 212*700637cbSDimitry Andric static const bool has_infinity = false; 213*700637cbSDimitry Andric static const bool has_quiet_NaN = false; 214*700637cbSDimitry Andric static const bool has_signaling_NaN = false; 215*700637cbSDimitry Andric static const float_denorm_style has_denorm = denorm_absent; 216*700637cbSDimitry Andric static const bool has_denorm_loss = false; 217*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type infinity() _NOEXCEPT { return type(0); } 218*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type quiet_NaN() _NOEXCEPT { return type(0); } 219*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type signaling_NaN() _NOEXCEPT { return type(0); } 220*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type denorm_min() _NOEXCEPT { return type(0); } 221*700637cbSDimitry Andric 222*700637cbSDimitry Andric static const bool is_iec559 = false; 223*700637cbSDimitry Andric static const bool is_bounded = true; 224*700637cbSDimitry Andric static const bool is_modulo = !std::is_signed<_Tp>::value; 225*700637cbSDimitry Andric 226*700637cbSDimitry Andric#if defined(__i386__) || defined(__x86_64__) || defined(__pnacl__) || defined(__wasm__) 227*700637cbSDimitry Andric static const bool traps = true; 228*700637cbSDimitry Andric#else 229*700637cbSDimitry Andric static const bool traps = false; 230*700637cbSDimitry Andric#endif 231*700637cbSDimitry Andric static const bool tinyness_before = false; 232*700637cbSDimitry Andric static const float_round_style round_style = round_toward_zero; 233*700637cbSDimitry Andric}; 234*700637cbSDimitry Andric 235*700637cbSDimitry Andrictemplate <> 236*700637cbSDimitry Andricclass __libcpp_numeric_limits<bool, true> { 237*700637cbSDimitry Andricprotected: 238*700637cbSDimitry Andric typedef bool type; 239*700637cbSDimitry Andric 240*700637cbSDimitry Andric static const bool is_specialized = true; 241*700637cbSDimitry Andric 242*700637cbSDimitry Andric static const bool is_signed = false; 243*700637cbSDimitry Andric static const int digits = 1; 244*700637cbSDimitry Andric static const int digits10 = 0; 245*700637cbSDimitry Andric static const int max_digits10 = 0; 246*700637cbSDimitry Andric static const type __min = false; 247*700637cbSDimitry Andric static const type __max = true; 248*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type min() _NOEXCEPT { return __min; } 249*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type max() _NOEXCEPT { return __max; } 250*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type lowest() _NOEXCEPT { return min(); } 251*700637cbSDimitry Andric 252*700637cbSDimitry Andric static const bool is_integer = true; 253*700637cbSDimitry Andric static const bool is_exact = true; 254*700637cbSDimitry Andric static const int radix = 2; 255*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type epsilon() _NOEXCEPT { return type(0); } 256*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type round_error() _NOEXCEPT { return type(0); } 257*700637cbSDimitry Andric 258*700637cbSDimitry Andric static const int min_exponent = 0; 259*700637cbSDimitry Andric static const int min_exponent10 = 0; 260*700637cbSDimitry Andric static const int max_exponent = 0; 261*700637cbSDimitry Andric static const int max_exponent10 = 0; 262*700637cbSDimitry Andric 263*700637cbSDimitry Andric static const bool has_infinity = false; 264*700637cbSDimitry Andric static const bool has_quiet_NaN = false; 265*700637cbSDimitry Andric static const bool has_signaling_NaN = false; 266*700637cbSDimitry Andric static const float_denorm_style has_denorm = denorm_absent; 267*700637cbSDimitry Andric static const bool has_denorm_loss = false; 268*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type infinity() _NOEXCEPT { return type(0); } 269*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type quiet_NaN() _NOEXCEPT { return type(0); } 270*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type signaling_NaN() _NOEXCEPT { return type(0); } 271*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type denorm_min() _NOEXCEPT { return type(0); } 272*700637cbSDimitry Andric 273*700637cbSDimitry Andric static const bool is_iec559 = false; 274*700637cbSDimitry Andric static const bool is_bounded = true; 275*700637cbSDimitry Andric static const bool is_modulo = false; 276*700637cbSDimitry Andric 277*700637cbSDimitry Andric static const bool traps = false; 278*700637cbSDimitry Andric static const bool tinyness_before = false; 279*700637cbSDimitry Andric static const float_round_style round_style = round_toward_zero; 280*700637cbSDimitry Andric}; 281*700637cbSDimitry Andric 282*700637cbSDimitry Andrictemplate <> 283*700637cbSDimitry Andricclass __libcpp_numeric_limits<float, true> { 284*700637cbSDimitry Andricprotected: 285*700637cbSDimitry Andric typedef float type; 286*700637cbSDimitry Andric 287*700637cbSDimitry Andric static const bool is_specialized = true; 288*700637cbSDimitry Andric 289*700637cbSDimitry Andric static const bool is_signed = true; 290*700637cbSDimitry Andric static const int digits = __FLT_MANT_DIG__; 291*700637cbSDimitry Andric static const int digits10 = __FLT_DIG__; 292*700637cbSDimitry Andric static const int max_digits10 = 2 + (digits * 30103l) / 100000l; 293*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type min() _NOEXCEPT { return __FLT_MIN__; } 294*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type max() _NOEXCEPT { return __FLT_MAX__; } 295*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type lowest() _NOEXCEPT { return -max(); } 296*700637cbSDimitry Andric 297*700637cbSDimitry Andric static const bool is_integer = false; 298*700637cbSDimitry Andric static const bool is_exact = false; 299*700637cbSDimitry Andric static const int radix = __FLT_RADIX__; 300*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type epsilon() _NOEXCEPT { return __FLT_EPSILON__; } 301*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type round_error() _NOEXCEPT { return 0.5F; } 302*700637cbSDimitry Andric 303*700637cbSDimitry Andric static const int min_exponent = __FLT_MIN_EXP__; 304*700637cbSDimitry Andric static const int min_exponent10 = __FLT_MIN_10_EXP__; 305*700637cbSDimitry Andric static const int max_exponent = __FLT_MAX_EXP__; 306*700637cbSDimitry Andric static const int max_exponent10 = __FLT_MAX_10_EXP__; 307*700637cbSDimitry Andric 308*700637cbSDimitry Andric static const bool has_infinity = true; 309*700637cbSDimitry Andric static const bool has_quiet_NaN = true; 310*700637cbSDimitry Andric static const bool has_signaling_NaN = true; 311*700637cbSDimitry Andric static const float_denorm_style has_denorm = denorm_present; 312*700637cbSDimitry Andric static const bool has_denorm_loss = false; 313*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type infinity() _NOEXCEPT { return __builtin_huge_valf(); } 314*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type quiet_NaN() _NOEXCEPT { return __builtin_nanf(""); } 315*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type signaling_NaN() _NOEXCEPT { return __builtin_nansf(""); } 316*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type denorm_min() _NOEXCEPT { return __FLT_DENORM_MIN__; } 317*700637cbSDimitry Andric 318*700637cbSDimitry Andric static const bool is_iec559 = true; 319*700637cbSDimitry Andric static const bool is_bounded = true; 320*700637cbSDimitry Andric static const bool is_modulo = false; 321*700637cbSDimitry Andric 322*700637cbSDimitry Andric static const bool traps = false; 323*700637cbSDimitry Andric#if (defined(__arm__) || defined(__aarch64__)) 324*700637cbSDimitry Andric static const bool tinyness_before = true; 325*700637cbSDimitry Andric#else 326*700637cbSDimitry Andric static const bool tinyness_before = false; 327*700637cbSDimitry Andric#endif 328*700637cbSDimitry Andric static const float_round_style round_style = round_to_nearest; 329*700637cbSDimitry Andric}; 330*700637cbSDimitry Andric 331*700637cbSDimitry Andrictemplate <> 332*700637cbSDimitry Andricclass __libcpp_numeric_limits<double, true> { 333*700637cbSDimitry Andricprotected: 334*700637cbSDimitry Andric typedef double type; 335*700637cbSDimitry Andric 336*700637cbSDimitry Andric static const bool is_specialized = true; 337*700637cbSDimitry Andric 338*700637cbSDimitry Andric static const bool is_signed = true; 339*700637cbSDimitry Andric static const int digits = __DBL_MANT_DIG__; 340*700637cbSDimitry Andric static const int digits10 = __DBL_DIG__; 341*700637cbSDimitry Andric static const int max_digits10 = 2 + (digits * 30103l) / 100000l; 342*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type min() _NOEXCEPT { return __DBL_MIN__; } 343*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type max() _NOEXCEPT { return __DBL_MAX__; } 344*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type lowest() _NOEXCEPT { return -max(); } 345*700637cbSDimitry Andric 346*700637cbSDimitry Andric static const bool is_integer = false; 347*700637cbSDimitry Andric static const bool is_exact = false; 348*700637cbSDimitry Andric static const int radix = __FLT_RADIX__; 349*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type epsilon() _NOEXCEPT { return __DBL_EPSILON__; } 350*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type round_error() _NOEXCEPT { return 0.5; } 351*700637cbSDimitry Andric 352*700637cbSDimitry Andric static const int min_exponent = __DBL_MIN_EXP__; 353*700637cbSDimitry Andric static const int min_exponent10 = __DBL_MIN_10_EXP__; 354*700637cbSDimitry Andric static const int max_exponent = __DBL_MAX_EXP__; 355*700637cbSDimitry Andric static const int max_exponent10 = __DBL_MAX_10_EXP__; 356*700637cbSDimitry Andric 357*700637cbSDimitry Andric static const bool has_infinity = true; 358*700637cbSDimitry Andric static const bool has_quiet_NaN = true; 359*700637cbSDimitry Andric static const bool has_signaling_NaN = true; 360*700637cbSDimitry Andric static const float_denorm_style has_denorm = denorm_present; 361*700637cbSDimitry Andric static const bool has_denorm_loss = false; 362*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type infinity() _NOEXCEPT { return __builtin_huge_val(); } 363*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type quiet_NaN() _NOEXCEPT { return __builtin_nan(""); } 364*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type signaling_NaN() _NOEXCEPT { return __builtin_nans(""); } 365*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type denorm_min() _NOEXCEPT { return __DBL_DENORM_MIN__; } 366*700637cbSDimitry Andric 367*700637cbSDimitry Andric static const bool is_iec559 = true; 368*700637cbSDimitry Andric static const bool is_bounded = true; 369*700637cbSDimitry Andric static const bool is_modulo = false; 370*700637cbSDimitry Andric 371*700637cbSDimitry Andric static const bool traps = false; 372*700637cbSDimitry Andric#if (defined(__arm__) || defined(__aarch64__)) 373*700637cbSDimitry Andric static const bool tinyness_before = true; 374*700637cbSDimitry Andric#else 375*700637cbSDimitry Andric static const bool tinyness_before = false; 376*700637cbSDimitry Andric#endif 377*700637cbSDimitry Andric static const float_round_style round_style = round_to_nearest; 378*700637cbSDimitry Andric}; 379*700637cbSDimitry Andric 380*700637cbSDimitry Andrictemplate <> 381*700637cbSDimitry Andricclass __libcpp_numeric_limits<long double, true> { 382*700637cbSDimitry Andricprotected: 383*700637cbSDimitry Andric typedef long double type; 384*700637cbSDimitry Andric 385*700637cbSDimitry Andric static const bool is_specialized = true; 386*700637cbSDimitry Andric 387*700637cbSDimitry Andric static const bool is_signed = true; 388*700637cbSDimitry Andric static const int digits = __LDBL_MANT_DIG__; 389*700637cbSDimitry Andric static const int digits10 = __LDBL_DIG__; 390*700637cbSDimitry Andric static const int max_digits10 = 2 + (digits * 30103l) / 100000l; 391*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type min() _NOEXCEPT { return __LDBL_MIN__; } 392*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type max() _NOEXCEPT { return __LDBL_MAX__; } 393*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type lowest() _NOEXCEPT { return -max(); } 394*700637cbSDimitry Andric 395*700637cbSDimitry Andric static const bool is_integer = false; 396*700637cbSDimitry Andric static const bool is_exact = false; 397*700637cbSDimitry Andric static const int radix = __FLT_RADIX__; 398*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type epsilon() _NOEXCEPT { return __LDBL_EPSILON__; } 399*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type round_error() _NOEXCEPT { return 0.5L; } 400*700637cbSDimitry Andric 401*700637cbSDimitry Andric static const int min_exponent = __LDBL_MIN_EXP__; 402*700637cbSDimitry Andric static const int min_exponent10 = __LDBL_MIN_10_EXP__; 403*700637cbSDimitry Andric static const int max_exponent = __LDBL_MAX_EXP__; 404*700637cbSDimitry Andric static const int max_exponent10 = __LDBL_MAX_10_EXP__; 405*700637cbSDimitry Andric 406*700637cbSDimitry Andric static const bool has_infinity = true; 407*700637cbSDimitry Andric static const bool has_quiet_NaN = true; 408*700637cbSDimitry Andric static const bool has_signaling_NaN = true; 409*700637cbSDimitry Andric static const float_denorm_style has_denorm = denorm_present; 410*700637cbSDimitry Andric static const bool has_denorm_loss = false; 411*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type infinity() _NOEXCEPT { return __builtin_huge_vall(); } 412*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type quiet_NaN() _NOEXCEPT { return __builtin_nanl(""); } 413*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type signaling_NaN() _NOEXCEPT { return __builtin_nansl(""); } 414*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type denorm_min() _NOEXCEPT { return __LDBL_DENORM_MIN__; } 415*700637cbSDimitry Andric 416*700637cbSDimitry Andric#if defined(__powerpc__) && defined(__LONG_DOUBLE_IBM128__) 417*700637cbSDimitry Andric static const bool is_iec559 = false; 418*700637cbSDimitry Andric#else 419*700637cbSDimitry Andric static const bool is_iec559 = true; 420*700637cbSDimitry Andric#endif 421*700637cbSDimitry Andric static const bool is_bounded = true; 422*700637cbSDimitry Andric static const bool is_modulo = false; 423*700637cbSDimitry Andric 424*700637cbSDimitry Andric static const bool traps = false; 425*700637cbSDimitry Andric#if (defined(__arm__) || defined(__aarch64__)) 426*700637cbSDimitry Andric static const bool tinyness_before = true; 427*700637cbSDimitry Andric#else 428*700637cbSDimitry Andric static const bool tinyness_before = false; 429*700637cbSDimitry Andric#endif 430*700637cbSDimitry Andric static const float_round_style round_style = round_to_nearest; 431*700637cbSDimitry Andric}; 432*700637cbSDimitry Andric 433*700637cbSDimitry Andrictemplate <class _Tp> 434*700637cbSDimitry Andricclass _LIBCPP_TEMPLATE_VIS numeric_limits : private __libcpp_numeric_limits<_Tp> { 435*700637cbSDimitry Andric typedef __libcpp_numeric_limits<_Tp> __base; 436*700637cbSDimitry Andric typedef typename __base::type type; 437*700637cbSDimitry Andric 438*700637cbSDimitry Andricpublic: 439*700637cbSDimitry Andric static const bool is_specialized = __base::is_specialized; 440*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type min() _NOEXCEPT { return __base::min(); } 441*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type max() _NOEXCEPT { return __base::max(); } 442*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type lowest() _NOEXCEPT { return __base::lowest(); } 443*700637cbSDimitry Andric 444*700637cbSDimitry Andric static const int digits = __base::digits; 445*700637cbSDimitry Andric static const int digits10 = __base::digits10; 446*700637cbSDimitry Andric static const int max_digits10 = __base::max_digits10; 447*700637cbSDimitry Andric static const bool is_signed = __base::is_signed; 448*700637cbSDimitry Andric static const bool is_integer = __base::is_integer; 449*700637cbSDimitry Andric static const bool is_exact = __base::is_exact; 450*700637cbSDimitry Andric static const int radix = __base::radix; 451*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type epsilon() _NOEXCEPT { return __base::epsilon(); } 452*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type round_error() _NOEXCEPT { return __base::round_error(); } 453*700637cbSDimitry Andric 454*700637cbSDimitry Andric static const int min_exponent = __base::min_exponent; 455*700637cbSDimitry Andric static const int min_exponent10 = __base::min_exponent10; 456*700637cbSDimitry Andric static const int max_exponent = __base::max_exponent; 457*700637cbSDimitry Andric static const int max_exponent10 = __base::max_exponent10; 458*700637cbSDimitry Andric 459*700637cbSDimitry Andric static const bool has_infinity = __base::has_infinity; 460*700637cbSDimitry Andric static const bool has_quiet_NaN = __base::has_quiet_NaN; 461*700637cbSDimitry Andric static const bool has_signaling_NaN = __base::has_signaling_NaN; 462*700637cbSDimitry Andric _LIBCPP_SUPPRESS_DEPRECATED_PUSH 463*700637cbSDimitry Andric static const float_denorm_style has_denorm = __base::has_denorm; 464*700637cbSDimitry Andric static const bool has_denorm_loss = __base::has_denorm_loss; 465*700637cbSDimitry Andric _LIBCPP_SUPPRESS_DEPRECATED_POP 466*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type infinity() _NOEXCEPT { return __base::infinity(); } 467*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type quiet_NaN() _NOEXCEPT { return __base::quiet_NaN(); } 468*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type signaling_NaN() _NOEXCEPT { return __base::signaling_NaN(); } 469*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static type denorm_min() _NOEXCEPT { return __base::denorm_min(); } 470*700637cbSDimitry Andric 471*700637cbSDimitry Andric static const bool is_iec559 = __base::is_iec559; 472*700637cbSDimitry Andric static const bool is_bounded = __base::is_bounded; 473*700637cbSDimitry Andric static const bool is_modulo = __base::is_modulo; 474*700637cbSDimitry Andric 475*700637cbSDimitry Andric static const bool traps = __base::traps; 476*700637cbSDimitry Andric static const bool tinyness_before = __base::tinyness_before; 477*700637cbSDimitry Andric static const float_round_style round_style = __base::round_style; 478*700637cbSDimitry Andric}; 479*700637cbSDimitry Andric 480*700637cbSDimitry Andrictemplate <class _Tp> 481*700637cbSDimitry Andricconst bool numeric_limits<_Tp>::is_specialized; 482*700637cbSDimitry Andrictemplate <class _Tp> 483*700637cbSDimitry Andricconst int numeric_limits<_Tp>::digits; 484*700637cbSDimitry Andrictemplate <class _Tp> 485*700637cbSDimitry Andricconst int numeric_limits<_Tp>::digits10; 486*700637cbSDimitry Andrictemplate <class _Tp> 487*700637cbSDimitry Andricconst int numeric_limits<_Tp>::max_digits10; 488*700637cbSDimitry Andrictemplate <class _Tp> 489*700637cbSDimitry Andricconst bool numeric_limits<_Tp>::is_signed; 490*700637cbSDimitry Andrictemplate <class _Tp> 491*700637cbSDimitry Andricconst bool numeric_limits<_Tp>::is_integer; 492*700637cbSDimitry Andrictemplate <class _Tp> 493*700637cbSDimitry Andricconst bool numeric_limits<_Tp>::is_exact; 494*700637cbSDimitry Andrictemplate <class _Tp> 495*700637cbSDimitry Andricconst int numeric_limits<_Tp>::radix; 496*700637cbSDimitry Andrictemplate <class _Tp> 497*700637cbSDimitry Andricconst int numeric_limits<_Tp>::min_exponent; 498*700637cbSDimitry Andrictemplate <class _Tp> 499*700637cbSDimitry Andricconst int numeric_limits<_Tp>::min_exponent10; 500*700637cbSDimitry Andrictemplate <class _Tp> 501*700637cbSDimitry Andricconst int numeric_limits<_Tp>::max_exponent; 502*700637cbSDimitry Andrictemplate <class _Tp> 503*700637cbSDimitry Andricconst int numeric_limits<_Tp>::max_exponent10; 504*700637cbSDimitry Andrictemplate <class _Tp> 505*700637cbSDimitry Andricconst bool numeric_limits<_Tp>::has_infinity; 506*700637cbSDimitry Andrictemplate <class _Tp> 507*700637cbSDimitry Andricconst bool numeric_limits<_Tp>::has_quiet_NaN; 508*700637cbSDimitry Andrictemplate <class _Tp> 509*700637cbSDimitry Andricconst bool numeric_limits<_Tp>::has_signaling_NaN; 510*700637cbSDimitry Andrictemplate <class _Tp> 511*700637cbSDimitry Andricconst float_denorm_style numeric_limits<_Tp>::has_denorm; 512*700637cbSDimitry Andrictemplate <class _Tp> 513*700637cbSDimitry Andricconst bool numeric_limits<_Tp>::has_denorm_loss; 514*700637cbSDimitry Andrictemplate <class _Tp> 515*700637cbSDimitry Andricconst bool numeric_limits<_Tp>::is_iec559; 516*700637cbSDimitry Andrictemplate <class _Tp> 517*700637cbSDimitry Andricconst bool numeric_limits<_Tp>::is_bounded; 518*700637cbSDimitry Andrictemplate <class _Tp> 519*700637cbSDimitry Andricconst bool numeric_limits<_Tp>::is_modulo; 520*700637cbSDimitry Andrictemplate <class _Tp> 521*700637cbSDimitry Andricconst bool numeric_limits<_Tp>::traps; 522*700637cbSDimitry Andrictemplate <class _Tp> 523*700637cbSDimitry Andricconst bool numeric_limits<_Tp>::tinyness_before; 524*700637cbSDimitry Andrictemplate <class _Tp> 525*700637cbSDimitry Andricconst float_round_style numeric_limits<_Tp>::round_style; 526*700637cbSDimitry Andric 527*700637cbSDimitry Andrictemplate <class _Tp> 528*700637cbSDimitry Andricclass _LIBCPP_TEMPLATE_VIS numeric_limits<const _Tp> : public numeric_limits<_Tp> {}; 529*700637cbSDimitry Andric 530*700637cbSDimitry Andrictemplate <class _Tp> 531*700637cbSDimitry Andricclass _LIBCPP_TEMPLATE_VIS numeric_limits<volatile _Tp> : public numeric_limits<_Tp> {}; 532*700637cbSDimitry Andric 533*700637cbSDimitry Andrictemplate <class _Tp> 534*700637cbSDimitry Andricclass _LIBCPP_TEMPLATE_VIS numeric_limits<const volatile _Tp> : public numeric_limits<_Tp> {}; 535*700637cbSDimitry Andric 536*700637cbSDimitry Andric_LIBCPP_END_NAMESPACE_STD 537*700637cbSDimitry Andric 538*700637cbSDimitry Andric_LIBCPP_POP_MACROS 539*700637cbSDimitry Andric 540*700637cbSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) 541*700637cbSDimitry Andric# include <__cxx03/type_traits> 542*700637cbSDimitry Andric#endif 543*700637cbSDimitry Andric 544*700637cbSDimitry Andric#endif // _LIBCPP___CXX03_LIMITS 545