limits 68 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826
  1. // The template and inlines for the numeric_limits classes. -*- C++ -*-
  2. // Copyright (C) 1999-2015 Free Software Foundation, Inc.
  3. //
  4. // This file is part of the GNU ISO C++ Library. This library is free
  5. // software; you can redistribute it and/or modify it under the
  6. // terms of the GNU General Public License as published by the
  7. // Free Software Foundation; either version 3, or (at your option)
  8. // any later version.
  9. // This library is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. // Under Section 7 of GPL version 3, you are granted additional
  14. // permissions described in the GCC Runtime Library Exception, version
  15. // 3.1, as published by the Free Software Foundation.
  16. // You should have received a copy of the GNU General Public License and
  17. // a copy of the GCC Runtime Library Exception along with this program;
  18. // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  19. // <http://www.gnu.org/licenses/>.
  20. /** @file include/limits
  21. * This is a Standard C++ Library header.
  22. */
  23. // Note: this is not a conforming implementation.
  24. // Written by Gabriel Dos Reis <gdr@codesourcery.com>
  25. //
  26. // ISO 14882:1998
  27. // 18.2.1
  28. //
  29. #ifndef _GLIBCXX_NUMERIC_LIMITS
  30. #define _GLIBCXX_NUMERIC_LIMITS 1
  31. #pragma GCC system_header
  32. #include <bits/c++config.h>
  33. //
  34. // The numeric_limits<> traits document implementation-defined aspects
  35. // of fundamental arithmetic data types (integers and floating points).
  36. // From Standard C++ point of view, there are 14 such types:
  37. // * integers
  38. // bool (1)
  39. // char, signed char, unsigned char, wchar_t (4)
  40. // short, unsigned short (2)
  41. // int, unsigned (2)
  42. // long, unsigned long (2)
  43. //
  44. // * floating points
  45. // float (1)
  46. // double (1)
  47. // long double (1)
  48. //
  49. // GNU C++ understands (where supported by the host C-library)
  50. // * integer
  51. // long long, unsigned long long (2)
  52. //
  53. // which brings us to 16 fundamental arithmetic data types in GNU C++.
  54. //
  55. //
  56. // Since a numeric_limits<> is a bit tricky to get right, we rely on
  57. // an interface composed of macros which should be defined in config/os
  58. // or config/cpu when they differ from the generic (read arbitrary)
  59. // definitions given here.
  60. //
  61. // These values can be overridden in the target configuration file.
  62. // The default values are appropriate for many 32-bit targets.
  63. // GCC only intrinsically supports modulo integral types. The only remaining
  64. // integral exceptional values is division by zero. Only targets that do not
  65. // signal division by zero in some "hard to ignore" way should use false.
  66. #ifndef __glibcxx_integral_traps
  67. # define __glibcxx_integral_traps true
  68. #endif
  69. // float
  70. //
  71. // Default values. Should be overridden in configuration files if necessary.
  72. #ifndef __glibcxx_float_has_denorm_loss
  73. # define __glibcxx_float_has_denorm_loss false
  74. #endif
  75. #ifndef __glibcxx_float_traps
  76. # define __glibcxx_float_traps false
  77. #endif
  78. #ifndef __glibcxx_float_tinyness_before
  79. # define __glibcxx_float_tinyness_before false
  80. #endif
  81. // double
  82. // Default values. Should be overridden in configuration files if necessary.
  83. #ifndef __glibcxx_double_has_denorm_loss
  84. # define __glibcxx_double_has_denorm_loss false
  85. #endif
  86. #ifndef __glibcxx_double_traps
  87. # define __glibcxx_double_traps false
  88. #endif
  89. #ifndef __glibcxx_double_tinyness_before
  90. # define __glibcxx_double_tinyness_before false
  91. #endif
  92. // long double
  93. // Default values. Should be overridden in configuration files if necessary.
  94. #ifndef __glibcxx_long_double_has_denorm_loss
  95. # define __glibcxx_long_double_has_denorm_loss false
  96. #endif
  97. #ifndef __glibcxx_long_double_traps
  98. # define __glibcxx_long_double_traps false
  99. #endif
  100. #ifndef __glibcxx_long_double_tinyness_before
  101. # define __glibcxx_long_double_tinyness_before false
  102. #endif
  103. // You should not need to define any macros below this point.
  104. #define __glibcxx_signed_b(T,B) ((T)(-1) < 0)
  105. #define __glibcxx_min_b(T,B) \
  106. (__glibcxx_signed_b (T,B) ? -__glibcxx_max_b (T,B) - 1 : (T)0)
  107. #define __glibcxx_max_b(T,B) \
  108. (__glibcxx_signed_b (T,B) ? \
  109. (((((T)1 << (__glibcxx_digits_b (T,B) - 1)) - 1) << 1) + 1) : ~(T)0)
  110. #define __glibcxx_digits_b(T,B) \
  111. (B - __glibcxx_signed_b (T,B))
  112. // The fraction 643/2136 approximates log10(2) to 7 significant digits.
  113. #define __glibcxx_digits10_b(T,B) \
  114. (__glibcxx_digits_b (T,B) * 643L / 2136)
  115. #define __glibcxx_signed(T) \
  116. __glibcxx_signed_b (T, sizeof(T) * __CHAR_BIT__)
  117. #define __glibcxx_min(T) \
  118. __glibcxx_min_b (T, sizeof(T) * __CHAR_BIT__)
  119. #define __glibcxx_max(T) \
  120. __glibcxx_max_b (T, sizeof(T) * __CHAR_BIT__)
  121. #define __glibcxx_digits(T) \
  122. __glibcxx_digits_b (T, sizeof(T) * __CHAR_BIT__)
  123. #define __glibcxx_digits10(T) \
  124. __glibcxx_digits10_b (T, sizeof(T) * __CHAR_BIT__)
  125. #define __glibcxx_max_digits10(T) \
  126. (2 + (T) * 643L / 2136)
  127. namespace std _GLIBCXX_VISIBILITY(default)
  128. {
  129. _GLIBCXX_BEGIN_NAMESPACE_VERSION
  130. /**
  131. * @brief Describes the rounding style for floating-point types.
  132. *
  133. * This is used in the std::numeric_limits class.
  134. */
  135. enum float_round_style
  136. {
  137. round_indeterminate = -1, /// Intermediate.
  138. round_toward_zero = 0, /// To zero.
  139. round_to_nearest = 1, /// To the nearest representable value.
  140. round_toward_infinity = 2, /// To infinity.
  141. round_toward_neg_infinity = 3 /// To negative infinity.
  142. };
  143. /**
  144. * @brief Describes the denormalization for floating-point types.
  145. *
  146. * These values represent the presence or absence of a variable number
  147. * of exponent bits. This type is used in the std::numeric_limits class.
  148. */
  149. enum float_denorm_style
  150. {
  151. /// Indeterminate at compile time whether denormalized values are allowed.
  152. denorm_indeterminate = -1,
  153. /// The type does not allow denormalized values.
  154. denorm_absent = 0,
  155. /// The type allows denormalized values.
  156. denorm_present = 1
  157. };
  158. /**
  159. * @brief Part of std::numeric_limits.
  160. *
  161. * The @c static @c const members are usable as integral constant
  162. * expressions.
  163. *
  164. * @note This is a separate class for purposes of efficiency; you
  165. * should only access these members as part of an instantiation
  166. * of the std::numeric_limits class.
  167. */
  168. struct __numeric_limits_base
  169. {
  170. /** This will be true for all fundamental types (which have
  171. specializations), and false for everything else. */
  172. static _GLIBCXX_USE_CONSTEXPR bool is_specialized = false;
  173. /** The number of @c radix digits that be represented without change: for
  174. integer types, the number of non-sign bits in the mantissa; for
  175. floating types, the number of @c radix digits in the mantissa. */
  176. static _GLIBCXX_USE_CONSTEXPR int digits = 0;
  177. /** The number of base 10 digits that can be represented without change. */
  178. static _GLIBCXX_USE_CONSTEXPR int digits10 = 0;
  179. #if __cplusplus >= 201103L
  180. /** The number of base 10 digits required to ensure that values which
  181. differ are always differentiated. */
  182. static constexpr int max_digits10 = 0;
  183. #endif
  184. /** True if the type is signed. */
  185. static _GLIBCXX_USE_CONSTEXPR bool is_signed = false;
  186. /** True if the type is integer. */
  187. static _GLIBCXX_USE_CONSTEXPR bool is_integer = false;
  188. /** True if the type uses an exact representation. All integer types are
  189. exact, but not all exact types are integer. For example, rational and
  190. fixed-exponent representations are exact but not integer. */
  191. static _GLIBCXX_USE_CONSTEXPR bool is_exact = false;
  192. /** For integer types, specifies the base of the representation. For
  193. floating types, specifies the base of the exponent representation. */
  194. static _GLIBCXX_USE_CONSTEXPR int radix = 0;
  195. /** The minimum negative integer such that @c radix raised to the power of
  196. (one less than that integer) is a normalized floating point number. */
  197. static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0;
  198. /** The minimum negative integer such that 10 raised to that power is in
  199. the range of normalized floating point numbers. */
  200. static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0;
  201. /** The maximum positive integer such that @c radix raised to the power of
  202. (one less than that integer) is a representable finite floating point
  203. number. */
  204. static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0;
  205. /** The maximum positive integer such that 10 raised to that power is in
  206. the range of representable finite floating point numbers. */
  207. static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0;
  208. /** True if the type has a representation for positive infinity. */
  209. static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false;
  210. /** True if the type has a representation for a quiet (non-signaling)
  211. Not a Number. */
  212. static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false;
  213. /** True if the type has a representation for a signaling
  214. Not a Number. */
  215. static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false;
  216. /** See std::float_denorm_style for more information. */
  217. static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm = denorm_absent;
  218. /** True if loss of accuracy is detected as a denormalization loss,
  219. rather than as an inexact result. */
  220. static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false;
  221. /** True if-and-only-if the type adheres to the IEC 559 standard, also
  222. known as IEEE 754. (Only makes sense for floating point types.) */
  223. static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false;
  224. /** True if the set of values representable by the type is
  225. finite. All built-in types are bounded, this member would be
  226. false for arbitrary precision types. */
  227. static _GLIBCXX_USE_CONSTEXPR bool is_bounded = false;
  228. /** True if the type is @e modulo. A type is modulo if, for any
  229. operation involving +, -, or * on values of that type whose
  230. result would fall outside the range [min(),max()], the value
  231. returned differs from the true value by an integer multiple of
  232. max() - min() + 1. On most machines, this is false for floating
  233. types, true for unsigned integers, and true for signed integers.
  234. See PR22200 about signed integers. */
  235. static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false;
  236. /** True if trapping is implemented for this type. */
  237. static _GLIBCXX_USE_CONSTEXPR bool traps = false;
  238. /** True if tininess is detected before rounding. (see IEC 559) */
  239. static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false;
  240. /** See std::float_round_style for more information. This is only
  241. meaningful for floating types; integer types will all be
  242. round_toward_zero. */
  243. static _GLIBCXX_USE_CONSTEXPR float_round_style round_style =
  244. round_toward_zero;
  245. };
  246. /**
  247. * @brief Properties of fundamental types.
  248. *
  249. * This class allows a program to obtain information about the
  250. * representation of a fundamental type on a given platform. For
  251. * non-fundamental types, the functions will return 0 and the data
  252. * members will all be @c false.
  253. *
  254. * _GLIBCXX_RESOLVE_LIB_DEFECTS: DRs 201 and 184 (hi Gaby!) are
  255. * noted, but not incorporated in this documented (yet).
  256. */
  257. template<typename _Tp>
  258. struct numeric_limits : public __numeric_limits_base
  259. {
  260. /** The minimum finite value, or for floating types with
  261. denormalization, the minimum positive normalized value. */
  262. static _GLIBCXX_CONSTEXPR _Tp
  263. min() _GLIBCXX_USE_NOEXCEPT { return _Tp(); }
  264. /** The maximum finite value. */
  265. static _GLIBCXX_CONSTEXPR _Tp
  266. max() _GLIBCXX_USE_NOEXCEPT { return _Tp(); }
  267. #if __cplusplus >= 201103L
  268. /** A finite value x such that there is no other finite value y
  269. * where y < x. */
  270. static constexpr _Tp
  271. lowest() noexcept { return _Tp(); }
  272. #endif
  273. /** The @e machine @e epsilon: the difference between 1 and the least
  274. value greater than 1 that is representable. */
  275. static _GLIBCXX_CONSTEXPR _Tp
  276. epsilon() _GLIBCXX_USE_NOEXCEPT { return _Tp(); }
  277. /** The maximum rounding error measurement (see LIA-1). */
  278. static _GLIBCXX_CONSTEXPR _Tp
  279. round_error() _GLIBCXX_USE_NOEXCEPT { return _Tp(); }
  280. /** The representation of positive infinity, if @c has_infinity. */
  281. static _GLIBCXX_CONSTEXPR _Tp
  282. infinity() _GLIBCXX_USE_NOEXCEPT { return _Tp(); }
  283. /** The representation of a quiet Not a Number,
  284. if @c has_quiet_NaN. */
  285. static _GLIBCXX_CONSTEXPR _Tp
  286. quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return _Tp(); }
  287. /** The representation of a signaling Not a Number, if
  288. @c has_signaling_NaN. */
  289. static _GLIBCXX_CONSTEXPR _Tp
  290. signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return _Tp(); }
  291. /** The minimum positive denormalized value. For types where
  292. @c has_denorm is false, this is the minimum positive normalized
  293. value. */
  294. static _GLIBCXX_CONSTEXPR _Tp
  295. denorm_min() _GLIBCXX_USE_NOEXCEPT { return _Tp(); }
  296. };
  297. #if __cplusplus >= 201103L
  298. template<typename _Tp>
  299. struct numeric_limits<const _Tp>
  300. : public numeric_limits<_Tp> { };
  301. template<typename _Tp>
  302. struct numeric_limits<volatile _Tp>
  303. : public numeric_limits<_Tp> { };
  304. template<typename _Tp>
  305. struct numeric_limits<const volatile _Tp>
  306. : public numeric_limits<_Tp> { };
  307. #endif
  308. // Now there follow 16 explicit specializations. Yes, 16. Make sure
  309. // you get the count right. (18 in c++0x mode)
  310. /// numeric_limits<bool> specialization.
  311. template<>
  312. struct numeric_limits<bool>
  313. {
  314. static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true;
  315. static _GLIBCXX_CONSTEXPR bool
  316. min() _GLIBCXX_USE_NOEXCEPT { return false; }
  317. static _GLIBCXX_CONSTEXPR bool
  318. max() _GLIBCXX_USE_NOEXCEPT { return true; }
  319. #if __cplusplus >= 201103L
  320. static constexpr bool
  321. lowest() noexcept { return min(); }
  322. #endif
  323. static _GLIBCXX_USE_CONSTEXPR int digits = 1;
  324. static _GLIBCXX_USE_CONSTEXPR int digits10 = 0;
  325. #if __cplusplus >= 201103L
  326. static constexpr int max_digits10 = 0;
  327. #endif
  328. static _GLIBCXX_USE_CONSTEXPR bool is_signed = false;
  329. static _GLIBCXX_USE_CONSTEXPR bool is_integer = true;
  330. static _GLIBCXX_USE_CONSTEXPR bool is_exact = true;
  331. static _GLIBCXX_USE_CONSTEXPR int radix = 2;
  332. static _GLIBCXX_CONSTEXPR bool
  333. epsilon() _GLIBCXX_USE_NOEXCEPT { return false; }
  334. static _GLIBCXX_CONSTEXPR bool
  335. round_error() _GLIBCXX_USE_NOEXCEPT { return false; }
  336. static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0;
  337. static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0;
  338. static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0;
  339. static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0;
  340. static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false;
  341. static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false;
  342. static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false;
  343. static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm
  344. = denorm_absent;
  345. static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false;
  346. static _GLIBCXX_CONSTEXPR bool
  347. infinity() _GLIBCXX_USE_NOEXCEPT { return false; }
  348. static _GLIBCXX_CONSTEXPR bool
  349. quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return false; }
  350. static _GLIBCXX_CONSTEXPR bool
  351. signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return false; }
  352. static _GLIBCXX_CONSTEXPR bool
  353. denorm_min() _GLIBCXX_USE_NOEXCEPT { return false; }
  354. static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false;
  355. static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true;
  356. static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false;
  357. // It is not clear what it means for a boolean type to trap.
  358. // This is a DR on the LWG issue list. Here, I use integer
  359. // promotion semantics.
  360. static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps;
  361. static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false;
  362. static _GLIBCXX_USE_CONSTEXPR float_round_style round_style
  363. = round_toward_zero;
  364. };
  365. /// numeric_limits<char> specialization.
  366. template<>
  367. struct numeric_limits<char>
  368. {
  369. static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true;
  370. static _GLIBCXX_CONSTEXPR char
  371. min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min(char); }
  372. static _GLIBCXX_CONSTEXPR char
  373. max() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_max(char); }
  374. #if __cplusplus >= 201103L
  375. static constexpr char
  376. lowest() noexcept { return min(); }
  377. #endif
  378. static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (char);
  379. static _GLIBCXX_USE_CONSTEXPR int digits10 = __glibcxx_digits10 (char);
  380. #if __cplusplus >= 201103L
  381. static constexpr int max_digits10 = 0;
  382. #endif
  383. static _GLIBCXX_USE_CONSTEXPR bool is_signed = __glibcxx_signed (char);
  384. static _GLIBCXX_USE_CONSTEXPR bool is_integer = true;
  385. static _GLIBCXX_USE_CONSTEXPR bool is_exact = true;
  386. static _GLIBCXX_USE_CONSTEXPR int radix = 2;
  387. static _GLIBCXX_CONSTEXPR char
  388. epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; }
  389. static _GLIBCXX_CONSTEXPR char
  390. round_error() _GLIBCXX_USE_NOEXCEPT { return 0; }
  391. static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0;
  392. static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0;
  393. static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0;
  394. static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0;
  395. static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false;
  396. static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false;
  397. static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false;
  398. static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm
  399. = denorm_absent;
  400. static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false;
  401. static _GLIBCXX_CONSTEXPR
  402. char infinity() _GLIBCXX_USE_NOEXCEPT { return char(); }
  403. static _GLIBCXX_CONSTEXPR char
  404. quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return char(); }
  405. static _GLIBCXX_CONSTEXPR char
  406. signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return char(); }
  407. static _GLIBCXX_CONSTEXPR char
  408. denorm_min() _GLIBCXX_USE_NOEXCEPT { return static_cast<char>(0); }
  409. static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false;
  410. static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true;
  411. static _GLIBCXX_USE_CONSTEXPR bool is_modulo = !is_signed;
  412. static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps;
  413. static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false;
  414. static _GLIBCXX_USE_CONSTEXPR float_round_style round_style
  415. = round_toward_zero;
  416. };
  417. /// numeric_limits<signed char> specialization.
  418. template<>
  419. struct numeric_limits<signed char>
  420. {
  421. static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true;
  422. static _GLIBCXX_CONSTEXPR signed char
  423. min() _GLIBCXX_USE_NOEXCEPT { return -__SCHAR_MAX__ - 1; }
  424. static _GLIBCXX_CONSTEXPR signed char
  425. max() _GLIBCXX_USE_NOEXCEPT { return __SCHAR_MAX__; }
  426. #if __cplusplus >= 201103L
  427. static constexpr signed char
  428. lowest() noexcept { return min(); }
  429. #endif
  430. static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (signed char);
  431. static _GLIBCXX_USE_CONSTEXPR int digits10
  432. = __glibcxx_digits10 (signed char);
  433. #if __cplusplus >= 201103L
  434. static constexpr int max_digits10 = 0;
  435. #endif
  436. static _GLIBCXX_USE_CONSTEXPR bool is_signed = true;
  437. static _GLIBCXX_USE_CONSTEXPR bool is_integer = true;
  438. static _GLIBCXX_USE_CONSTEXPR bool is_exact = true;
  439. static _GLIBCXX_USE_CONSTEXPR int radix = 2;
  440. static _GLIBCXX_CONSTEXPR signed char
  441. epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; }
  442. static _GLIBCXX_CONSTEXPR signed char
  443. round_error() _GLIBCXX_USE_NOEXCEPT { return 0; }
  444. static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0;
  445. static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0;
  446. static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0;
  447. static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0;
  448. static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false;
  449. static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false;
  450. static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false;
  451. static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm
  452. = denorm_absent;
  453. static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false;
  454. static _GLIBCXX_CONSTEXPR signed char
  455. infinity() _GLIBCXX_USE_NOEXCEPT { return static_cast<signed char>(0); }
  456. static _GLIBCXX_CONSTEXPR signed char
  457. quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast<signed char>(0); }
  458. static _GLIBCXX_CONSTEXPR signed char
  459. signaling_NaN() _GLIBCXX_USE_NOEXCEPT
  460. { return static_cast<signed char>(0); }
  461. static _GLIBCXX_CONSTEXPR signed char
  462. denorm_min() _GLIBCXX_USE_NOEXCEPT
  463. { return static_cast<signed char>(0); }
  464. static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false;
  465. static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true;
  466. static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false;
  467. static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps;
  468. static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false;
  469. static _GLIBCXX_USE_CONSTEXPR float_round_style round_style
  470. = round_toward_zero;
  471. };
  472. /// numeric_limits<unsigned char> specialization.
  473. template<>
  474. struct numeric_limits<unsigned char>
  475. {
  476. static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true;
  477. static _GLIBCXX_CONSTEXPR unsigned char
  478. min() _GLIBCXX_USE_NOEXCEPT { return 0; }
  479. static _GLIBCXX_CONSTEXPR unsigned char
  480. max() _GLIBCXX_USE_NOEXCEPT { return __SCHAR_MAX__ * 2U + 1; }
  481. #if __cplusplus >= 201103L
  482. static constexpr unsigned char
  483. lowest() noexcept { return min(); }
  484. #endif
  485. static _GLIBCXX_USE_CONSTEXPR int digits
  486. = __glibcxx_digits (unsigned char);
  487. static _GLIBCXX_USE_CONSTEXPR int digits10
  488. = __glibcxx_digits10 (unsigned char);
  489. #if __cplusplus >= 201103L
  490. static constexpr int max_digits10 = 0;
  491. #endif
  492. static _GLIBCXX_USE_CONSTEXPR bool is_signed = false;
  493. static _GLIBCXX_USE_CONSTEXPR bool is_integer = true;
  494. static _GLIBCXX_USE_CONSTEXPR bool is_exact = true;
  495. static _GLIBCXX_USE_CONSTEXPR int radix = 2;
  496. static _GLIBCXX_CONSTEXPR unsigned char
  497. epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; }
  498. static _GLIBCXX_CONSTEXPR unsigned char
  499. round_error() _GLIBCXX_USE_NOEXCEPT { return 0; }
  500. static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0;
  501. static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0;
  502. static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0;
  503. static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0;
  504. static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false;
  505. static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false;
  506. static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false;
  507. static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm
  508. = denorm_absent;
  509. static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false;
  510. static _GLIBCXX_CONSTEXPR unsigned char
  511. infinity() _GLIBCXX_USE_NOEXCEPT
  512. { return static_cast<unsigned char>(0); }
  513. static _GLIBCXX_CONSTEXPR unsigned char
  514. quiet_NaN() _GLIBCXX_USE_NOEXCEPT
  515. { return static_cast<unsigned char>(0); }
  516. static _GLIBCXX_CONSTEXPR unsigned char
  517. signaling_NaN() _GLIBCXX_USE_NOEXCEPT
  518. { return static_cast<unsigned char>(0); }
  519. static _GLIBCXX_CONSTEXPR unsigned char
  520. denorm_min() _GLIBCXX_USE_NOEXCEPT
  521. { return static_cast<unsigned char>(0); }
  522. static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false;
  523. static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true;
  524. static _GLIBCXX_USE_CONSTEXPR bool is_modulo = true;
  525. static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps;
  526. static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false;
  527. static _GLIBCXX_USE_CONSTEXPR float_round_style round_style
  528. = round_toward_zero;
  529. };
  530. /// numeric_limits<wchar_t> specialization.
  531. template<>
  532. struct numeric_limits<wchar_t>
  533. {
  534. static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true;
  535. static _GLIBCXX_CONSTEXPR wchar_t
  536. min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min (wchar_t); }
  537. static _GLIBCXX_CONSTEXPR wchar_t
  538. max() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_max (wchar_t); }
  539. #if __cplusplus >= 201103L
  540. static constexpr wchar_t
  541. lowest() noexcept { return min(); }
  542. #endif
  543. static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (wchar_t);
  544. static _GLIBCXX_USE_CONSTEXPR int digits10
  545. = __glibcxx_digits10 (wchar_t);
  546. #if __cplusplus >= 201103L
  547. static constexpr int max_digits10 = 0;
  548. #endif
  549. static _GLIBCXX_USE_CONSTEXPR bool is_signed = __glibcxx_signed (wchar_t);
  550. static _GLIBCXX_USE_CONSTEXPR bool is_integer = true;
  551. static _GLIBCXX_USE_CONSTEXPR bool is_exact = true;
  552. static _GLIBCXX_USE_CONSTEXPR int radix = 2;
  553. static _GLIBCXX_CONSTEXPR wchar_t
  554. epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; }
  555. static _GLIBCXX_CONSTEXPR wchar_t
  556. round_error() _GLIBCXX_USE_NOEXCEPT { return 0; }
  557. static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0;
  558. static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0;
  559. static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0;
  560. static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0;
  561. static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false;
  562. static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false;
  563. static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false;
  564. static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm
  565. = denorm_absent;
  566. static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false;
  567. static _GLIBCXX_CONSTEXPR wchar_t
  568. infinity() _GLIBCXX_USE_NOEXCEPT { return wchar_t(); }
  569. static _GLIBCXX_CONSTEXPR wchar_t
  570. quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return wchar_t(); }
  571. static _GLIBCXX_CONSTEXPR wchar_t
  572. signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return wchar_t(); }
  573. static _GLIBCXX_CONSTEXPR wchar_t
  574. denorm_min() _GLIBCXX_USE_NOEXCEPT { return wchar_t(); }
  575. static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false;
  576. static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true;
  577. static _GLIBCXX_USE_CONSTEXPR bool is_modulo = !is_signed;
  578. static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps;
  579. static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false;
  580. static _GLIBCXX_USE_CONSTEXPR float_round_style round_style
  581. = round_toward_zero;
  582. };
  583. #if __cplusplus >= 201103L
  584. /// numeric_limits<char16_t> specialization.
  585. template<>
  586. struct numeric_limits<char16_t>
  587. {
  588. static constexpr bool is_specialized = true;
  589. static constexpr char16_t
  590. min() noexcept { return __glibcxx_min (char16_t); }
  591. static constexpr char16_t
  592. max() noexcept { return __glibcxx_max (char16_t); }
  593. static constexpr char16_t
  594. lowest() noexcept { return min(); }
  595. static constexpr int digits = __glibcxx_digits (char16_t);
  596. static constexpr int digits10 = __glibcxx_digits10 (char16_t);
  597. static constexpr int max_digits10 = 0;
  598. static constexpr bool is_signed = __glibcxx_signed (char16_t);
  599. static constexpr bool is_integer = true;
  600. static constexpr bool is_exact = true;
  601. static constexpr int radix = 2;
  602. static constexpr char16_t
  603. epsilon() noexcept { return 0; }
  604. static constexpr char16_t
  605. round_error() noexcept { return 0; }
  606. static constexpr int min_exponent = 0;
  607. static constexpr int min_exponent10 = 0;
  608. static constexpr int max_exponent = 0;
  609. static constexpr int max_exponent10 = 0;
  610. static constexpr bool has_infinity = false;
  611. static constexpr bool has_quiet_NaN = false;
  612. static constexpr bool has_signaling_NaN = false;
  613. static constexpr float_denorm_style has_denorm = denorm_absent;
  614. static constexpr bool has_denorm_loss = false;
  615. static constexpr char16_t
  616. infinity() noexcept { return char16_t(); }
  617. static constexpr char16_t
  618. quiet_NaN() noexcept { return char16_t(); }
  619. static constexpr char16_t
  620. signaling_NaN() noexcept { return char16_t(); }
  621. static constexpr char16_t
  622. denorm_min() noexcept { return char16_t(); }
  623. static constexpr bool is_iec559 = false;
  624. static constexpr bool is_bounded = true;
  625. static constexpr bool is_modulo = !is_signed;
  626. static constexpr bool traps = __glibcxx_integral_traps;
  627. static constexpr bool tinyness_before = false;
  628. static constexpr float_round_style round_style = round_toward_zero;
  629. };
  630. /// numeric_limits<char32_t> specialization.
  631. template<>
  632. struct numeric_limits<char32_t>
  633. {
  634. static constexpr bool is_specialized = true;
  635. static constexpr char32_t
  636. min() noexcept { return __glibcxx_min (char32_t); }
  637. static constexpr char32_t
  638. max() noexcept { return __glibcxx_max (char32_t); }
  639. static constexpr char32_t
  640. lowest() noexcept { return min(); }
  641. static constexpr int digits = __glibcxx_digits (char32_t);
  642. static constexpr int digits10 = __glibcxx_digits10 (char32_t);
  643. static constexpr int max_digits10 = 0;
  644. static constexpr bool is_signed = __glibcxx_signed (char32_t);
  645. static constexpr bool is_integer = true;
  646. static constexpr bool is_exact = true;
  647. static constexpr int radix = 2;
  648. static constexpr char32_t
  649. epsilon() noexcept { return 0; }
  650. static constexpr char32_t
  651. round_error() noexcept { return 0; }
  652. static constexpr int min_exponent = 0;
  653. static constexpr int min_exponent10 = 0;
  654. static constexpr int max_exponent = 0;
  655. static constexpr int max_exponent10 = 0;
  656. static constexpr bool has_infinity = false;
  657. static constexpr bool has_quiet_NaN = false;
  658. static constexpr bool has_signaling_NaN = false;
  659. static constexpr float_denorm_style has_denorm = denorm_absent;
  660. static constexpr bool has_denorm_loss = false;
  661. static constexpr char32_t
  662. infinity() noexcept { return char32_t(); }
  663. static constexpr char32_t
  664. quiet_NaN() noexcept { return char32_t(); }
  665. static constexpr char32_t
  666. signaling_NaN() noexcept { return char32_t(); }
  667. static constexpr char32_t
  668. denorm_min() noexcept { return char32_t(); }
  669. static constexpr bool is_iec559 = false;
  670. static constexpr bool is_bounded = true;
  671. static constexpr bool is_modulo = !is_signed;
  672. static constexpr bool traps = __glibcxx_integral_traps;
  673. static constexpr bool tinyness_before = false;
  674. static constexpr float_round_style round_style = round_toward_zero;
  675. };
  676. #endif
  677. /// numeric_limits<short> specialization.
  678. template<>
  679. struct numeric_limits<short>
  680. {
  681. static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true;
  682. static _GLIBCXX_CONSTEXPR short
  683. min() _GLIBCXX_USE_NOEXCEPT { return -__SHRT_MAX__ - 1; }
  684. static _GLIBCXX_CONSTEXPR short
  685. max() _GLIBCXX_USE_NOEXCEPT { return __SHRT_MAX__; }
  686. #if __cplusplus >= 201103L
  687. static constexpr short
  688. lowest() noexcept { return min(); }
  689. #endif
  690. static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (short);
  691. static _GLIBCXX_USE_CONSTEXPR int digits10 = __glibcxx_digits10 (short);
  692. #if __cplusplus >= 201103L
  693. static constexpr int max_digits10 = 0;
  694. #endif
  695. static _GLIBCXX_USE_CONSTEXPR bool is_signed = true;
  696. static _GLIBCXX_USE_CONSTEXPR bool is_integer = true;
  697. static _GLIBCXX_USE_CONSTEXPR bool is_exact = true;
  698. static _GLIBCXX_USE_CONSTEXPR int radix = 2;
  699. static _GLIBCXX_CONSTEXPR short
  700. epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; }
  701. static _GLIBCXX_CONSTEXPR short
  702. round_error() _GLIBCXX_USE_NOEXCEPT { return 0; }
  703. static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0;
  704. static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0;
  705. static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0;
  706. static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0;
  707. static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false;
  708. static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false;
  709. static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false;
  710. static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm
  711. = denorm_absent;
  712. static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false;
  713. static _GLIBCXX_CONSTEXPR short
  714. infinity() _GLIBCXX_USE_NOEXCEPT { return short(); }
  715. static _GLIBCXX_CONSTEXPR short
  716. quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return short(); }
  717. static _GLIBCXX_CONSTEXPR short
  718. signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return short(); }
  719. static _GLIBCXX_CONSTEXPR short
  720. denorm_min() _GLIBCXX_USE_NOEXCEPT { return short(); }
  721. static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false;
  722. static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true;
  723. static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false;
  724. static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps;
  725. static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false;
  726. static _GLIBCXX_USE_CONSTEXPR float_round_style round_style
  727. = round_toward_zero;
  728. };
  729. /// numeric_limits<unsigned short> specialization.
  730. template<>
  731. struct numeric_limits<unsigned short>
  732. {
  733. static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true;
  734. static _GLIBCXX_CONSTEXPR unsigned short
  735. min() _GLIBCXX_USE_NOEXCEPT { return 0; }
  736. static _GLIBCXX_CONSTEXPR unsigned short
  737. max() _GLIBCXX_USE_NOEXCEPT { return __SHRT_MAX__ * 2U + 1; }
  738. #if __cplusplus >= 201103L
  739. static constexpr unsigned short
  740. lowest() noexcept { return min(); }
  741. #endif
  742. static _GLIBCXX_USE_CONSTEXPR int digits
  743. = __glibcxx_digits (unsigned short);
  744. static _GLIBCXX_USE_CONSTEXPR int digits10
  745. = __glibcxx_digits10 (unsigned short);
  746. #if __cplusplus >= 201103L
  747. static constexpr int max_digits10 = 0;
  748. #endif
  749. static _GLIBCXX_USE_CONSTEXPR bool is_signed = false;
  750. static _GLIBCXX_USE_CONSTEXPR bool is_integer = true;
  751. static _GLIBCXX_USE_CONSTEXPR bool is_exact = true;
  752. static _GLIBCXX_USE_CONSTEXPR int radix = 2;
  753. static _GLIBCXX_CONSTEXPR unsigned short
  754. epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; }
  755. static _GLIBCXX_CONSTEXPR unsigned short
  756. round_error() _GLIBCXX_USE_NOEXCEPT { return 0; }
  757. static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0;
  758. static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0;
  759. static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0;
  760. static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0;
  761. static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false;
  762. static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false;
  763. static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false;
  764. static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm
  765. = denorm_absent;
  766. static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false;
  767. static _GLIBCXX_CONSTEXPR unsigned short
  768. infinity() _GLIBCXX_USE_NOEXCEPT
  769. { return static_cast<unsigned short>(0); }
  770. static _GLIBCXX_CONSTEXPR unsigned short
  771. quiet_NaN() _GLIBCXX_USE_NOEXCEPT
  772. { return static_cast<unsigned short>(0); }
  773. static _GLIBCXX_CONSTEXPR unsigned short
  774. signaling_NaN() _GLIBCXX_USE_NOEXCEPT
  775. { return static_cast<unsigned short>(0); }
  776. static _GLIBCXX_CONSTEXPR unsigned short
  777. denorm_min() _GLIBCXX_USE_NOEXCEPT
  778. { return static_cast<unsigned short>(0); }
  779. static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false;
  780. static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true;
  781. static _GLIBCXX_USE_CONSTEXPR bool is_modulo = true;
  782. static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps;
  783. static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false;
  784. static _GLIBCXX_USE_CONSTEXPR float_round_style round_style
  785. = round_toward_zero;
  786. };
  787. /// numeric_limits<int> specialization.
  788. template<>
  789. struct numeric_limits<int>
  790. {
  791. static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true;
  792. static _GLIBCXX_CONSTEXPR int
  793. min() _GLIBCXX_USE_NOEXCEPT { return -__INT_MAX__ - 1; }
  794. static _GLIBCXX_CONSTEXPR int
  795. max() _GLIBCXX_USE_NOEXCEPT { return __INT_MAX__; }
  796. #if __cplusplus >= 201103L
  797. static constexpr int
  798. lowest() noexcept { return min(); }
  799. #endif
  800. static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (int);
  801. static _GLIBCXX_USE_CONSTEXPR int digits10 = __glibcxx_digits10 (int);
  802. #if __cplusplus >= 201103L
  803. static constexpr int max_digits10 = 0;
  804. #endif
  805. static _GLIBCXX_USE_CONSTEXPR bool is_signed = true;
  806. static _GLIBCXX_USE_CONSTEXPR bool is_integer = true;
  807. static _GLIBCXX_USE_CONSTEXPR bool is_exact = true;
  808. static _GLIBCXX_USE_CONSTEXPR int radix = 2;
  809. static _GLIBCXX_CONSTEXPR int
  810. epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; }
  811. static _GLIBCXX_CONSTEXPR int
  812. round_error() _GLIBCXX_USE_NOEXCEPT { return 0; }
  813. static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0;
  814. static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0;
  815. static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0;
  816. static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0;
  817. static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false;
  818. static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false;
  819. static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false;
  820. static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm
  821. = denorm_absent;
  822. static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false;
  823. static _GLIBCXX_CONSTEXPR int
  824. infinity() _GLIBCXX_USE_NOEXCEPT { return static_cast<int>(0); }
  825. static _GLIBCXX_CONSTEXPR int
  826. quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast<int>(0); }
  827. static _GLIBCXX_CONSTEXPR int
  828. signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast<int>(0); }
  829. static _GLIBCXX_CONSTEXPR int
  830. denorm_min() _GLIBCXX_USE_NOEXCEPT { return static_cast<int>(0); }
  831. static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false;
  832. static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true;
  833. static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false;
  834. static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps;
  835. static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false;
  836. static _GLIBCXX_USE_CONSTEXPR float_round_style round_style
  837. = round_toward_zero;
  838. };
  839. /// numeric_limits<unsigned int> specialization.
  840. template<>
  841. struct numeric_limits<unsigned int>
  842. {
  843. static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true;
  844. static _GLIBCXX_CONSTEXPR unsigned int
  845. min() _GLIBCXX_USE_NOEXCEPT { return 0; }
  846. static _GLIBCXX_CONSTEXPR unsigned int
  847. max() _GLIBCXX_USE_NOEXCEPT { return __INT_MAX__ * 2U + 1; }
  848. #if __cplusplus >= 201103L
  849. static constexpr unsigned int
  850. lowest() noexcept { return min(); }
  851. #endif
  852. static _GLIBCXX_USE_CONSTEXPR int digits
  853. = __glibcxx_digits (unsigned int);
  854. static _GLIBCXX_USE_CONSTEXPR int digits10
  855. = __glibcxx_digits10 (unsigned int);
  856. #if __cplusplus >= 201103L
  857. static constexpr int max_digits10 = 0;
  858. #endif
  859. static _GLIBCXX_USE_CONSTEXPR bool is_signed = false;
  860. static _GLIBCXX_USE_CONSTEXPR bool is_integer = true;
  861. static _GLIBCXX_USE_CONSTEXPR bool is_exact = true;
  862. static _GLIBCXX_USE_CONSTEXPR int radix = 2;
  863. static _GLIBCXX_CONSTEXPR unsigned int
  864. epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; }
  865. static _GLIBCXX_CONSTEXPR unsigned int
  866. round_error() _GLIBCXX_USE_NOEXCEPT { return 0; }
  867. static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0;
  868. static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0;
  869. static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0;
  870. static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0;
  871. static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false;
  872. static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false;
  873. static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false;
  874. static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm
  875. = denorm_absent;
  876. static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false;
  877. static _GLIBCXX_CONSTEXPR unsigned int
  878. infinity() _GLIBCXX_USE_NOEXCEPT { return static_cast<unsigned int>(0); }
  879. static _GLIBCXX_CONSTEXPR unsigned int
  880. quiet_NaN() _GLIBCXX_USE_NOEXCEPT
  881. { return static_cast<unsigned int>(0); }
  882. static _GLIBCXX_CONSTEXPR unsigned int
  883. signaling_NaN() _GLIBCXX_USE_NOEXCEPT
  884. { return static_cast<unsigned int>(0); }
  885. static _GLIBCXX_CONSTEXPR unsigned int
  886. denorm_min() _GLIBCXX_USE_NOEXCEPT
  887. { return static_cast<unsigned int>(0); }
  888. static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false;
  889. static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true;
  890. static _GLIBCXX_USE_CONSTEXPR bool is_modulo = true;
  891. static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps;
  892. static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false;
  893. static _GLIBCXX_USE_CONSTEXPR float_round_style round_style
  894. = round_toward_zero;
  895. };
  896. /// numeric_limits<long> specialization.
  897. template<>
  898. struct numeric_limits<long>
  899. {
  900. static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true;
  901. static _GLIBCXX_CONSTEXPR long
  902. min() _GLIBCXX_USE_NOEXCEPT { return -__LONG_MAX__ - 1; }
  903. static _GLIBCXX_CONSTEXPR long
  904. max() _GLIBCXX_USE_NOEXCEPT { return __LONG_MAX__; }
  905. #if __cplusplus >= 201103L
  906. static constexpr long
  907. lowest() noexcept { return min(); }
  908. #endif
  909. static _GLIBCXX_USE_CONSTEXPR int digits = __glibcxx_digits (long);
  910. static _GLIBCXX_USE_CONSTEXPR int digits10 = __glibcxx_digits10 (long);
  911. #if __cplusplus >= 201103L
  912. static constexpr int max_digits10 = 0;
  913. #endif
  914. static _GLIBCXX_USE_CONSTEXPR bool is_signed = true;
  915. static _GLIBCXX_USE_CONSTEXPR bool is_integer = true;
  916. static _GLIBCXX_USE_CONSTEXPR bool is_exact = true;
  917. static _GLIBCXX_USE_CONSTEXPR int radix = 2;
  918. static _GLIBCXX_CONSTEXPR long
  919. epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; }
  920. static _GLIBCXX_CONSTEXPR long
  921. round_error() _GLIBCXX_USE_NOEXCEPT { return 0; }
  922. static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0;
  923. static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0;
  924. static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0;
  925. static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0;
  926. static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false;
  927. static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false;
  928. static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false;
  929. static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm
  930. = denorm_absent;
  931. static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false;
  932. static _GLIBCXX_CONSTEXPR long
  933. infinity() _GLIBCXX_USE_NOEXCEPT { return static_cast<long>(0); }
  934. static _GLIBCXX_CONSTEXPR long
  935. quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast<long>(0); }
  936. static _GLIBCXX_CONSTEXPR long
  937. signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast<long>(0); }
  938. static _GLIBCXX_CONSTEXPR long
  939. denorm_min() _GLIBCXX_USE_NOEXCEPT { return static_cast<long>(0); }
  940. static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false;
  941. static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true;
  942. static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false;
  943. static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps;
  944. static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false;
  945. static _GLIBCXX_USE_CONSTEXPR float_round_style round_style
  946. = round_toward_zero;
  947. };
  948. /// numeric_limits<unsigned long> specialization.
  949. template<>
  950. struct numeric_limits<unsigned long>
  951. {
  952. static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true;
  953. static _GLIBCXX_CONSTEXPR unsigned long
  954. min() _GLIBCXX_USE_NOEXCEPT { return 0; }
  955. static _GLIBCXX_CONSTEXPR unsigned long
  956. max() _GLIBCXX_USE_NOEXCEPT { return __LONG_MAX__ * 2UL + 1; }
  957. #if __cplusplus >= 201103L
  958. static constexpr unsigned long
  959. lowest() noexcept { return min(); }
  960. #endif
  961. static _GLIBCXX_USE_CONSTEXPR int digits
  962. = __glibcxx_digits (unsigned long);
  963. static _GLIBCXX_USE_CONSTEXPR int digits10
  964. = __glibcxx_digits10 (unsigned long);
  965. #if __cplusplus >= 201103L
  966. static constexpr int max_digits10 = 0;
  967. #endif
  968. static _GLIBCXX_USE_CONSTEXPR bool is_signed = false;
  969. static _GLIBCXX_USE_CONSTEXPR bool is_integer = true;
  970. static _GLIBCXX_USE_CONSTEXPR bool is_exact = true;
  971. static _GLIBCXX_USE_CONSTEXPR int radix = 2;
  972. static _GLIBCXX_CONSTEXPR unsigned long
  973. epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; }
  974. static _GLIBCXX_CONSTEXPR unsigned long
  975. round_error() _GLIBCXX_USE_NOEXCEPT { return 0; }
  976. static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0;
  977. static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0;
  978. static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0;
  979. static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0;
  980. static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false;
  981. static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false;
  982. static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false;
  983. static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm
  984. = denorm_absent;
  985. static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false;
  986. static _GLIBCXX_CONSTEXPR unsigned long
  987. infinity() _GLIBCXX_USE_NOEXCEPT
  988. { return static_cast<unsigned long>(0); }
  989. static _GLIBCXX_CONSTEXPR unsigned long
  990. quiet_NaN() _GLIBCXX_USE_NOEXCEPT
  991. { return static_cast<unsigned long>(0); }
  992. static _GLIBCXX_CONSTEXPR unsigned long
  993. signaling_NaN() _GLIBCXX_USE_NOEXCEPT
  994. { return static_cast<unsigned long>(0); }
  995. static _GLIBCXX_CONSTEXPR unsigned long
  996. denorm_min() _GLIBCXX_USE_NOEXCEPT
  997. { return static_cast<unsigned long>(0); }
  998. static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false;
  999. static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true;
  1000. static _GLIBCXX_USE_CONSTEXPR bool is_modulo = true;
  1001. static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps;
  1002. static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false;
  1003. static _GLIBCXX_USE_CONSTEXPR float_round_style round_style
  1004. = round_toward_zero;
  1005. };
  1006. /// numeric_limits<long long> specialization.
  1007. template<>
  1008. struct numeric_limits<long long>
  1009. {
  1010. static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true;
  1011. static _GLIBCXX_CONSTEXPR long long
  1012. min() _GLIBCXX_USE_NOEXCEPT { return -__LONG_LONG_MAX__ - 1; }
  1013. static _GLIBCXX_CONSTEXPR long long
  1014. max() _GLIBCXX_USE_NOEXCEPT { return __LONG_LONG_MAX__; }
  1015. #if __cplusplus >= 201103L
  1016. static constexpr long long
  1017. lowest() noexcept { return min(); }
  1018. #endif
  1019. static _GLIBCXX_USE_CONSTEXPR int digits
  1020. = __glibcxx_digits (long long);
  1021. static _GLIBCXX_USE_CONSTEXPR int digits10
  1022. = __glibcxx_digits10 (long long);
  1023. #if __cplusplus >= 201103L
  1024. static constexpr int max_digits10 = 0;
  1025. #endif
  1026. static _GLIBCXX_USE_CONSTEXPR bool is_signed = true;
  1027. static _GLIBCXX_USE_CONSTEXPR bool is_integer = true;
  1028. static _GLIBCXX_USE_CONSTEXPR bool is_exact = true;
  1029. static _GLIBCXX_USE_CONSTEXPR int radix = 2;
  1030. static _GLIBCXX_CONSTEXPR long long
  1031. epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; }
  1032. static _GLIBCXX_CONSTEXPR long long
  1033. round_error() _GLIBCXX_USE_NOEXCEPT { return 0; }
  1034. static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0;
  1035. static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0;
  1036. static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0;
  1037. static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0;
  1038. static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false;
  1039. static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false;
  1040. static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false;
  1041. static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm
  1042. = denorm_absent;
  1043. static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false;
  1044. static _GLIBCXX_CONSTEXPR long long
  1045. infinity() _GLIBCXX_USE_NOEXCEPT { return static_cast<long long>(0); }
  1046. static _GLIBCXX_CONSTEXPR long long
  1047. quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return static_cast<long long>(0); }
  1048. static _GLIBCXX_CONSTEXPR long long
  1049. signaling_NaN() _GLIBCXX_USE_NOEXCEPT
  1050. { return static_cast<long long>(0); }
  1051. static _GLIBCXX_CONSTEXPR long long
  1052. denorm_min() _GLIBCXX_USE_NOEXCEPT { return static_cast<long long>(0); }
  1053. static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false;
  1054. static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true;
  1055. static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false;
  1056. static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps;
  1057. static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false;
  1058. static _GLIBCXX_USE_CONSTEXPR float_round_style round_style
  1059. = round_toward_zero;
  1060. };
  1061. /// numeric_limits<unsigned long long> specialization.
  1062. template<>
  1063. struct numeric_limits<unsigned long long>
  1064. {
  1065. static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true;
  1066. static _GLIBCXX_CONSTEXPR unsigned long long
  1067. min() _GLIBCXX_USE_NOEXCEPT { return 0; }
  1068. static _GLIBCXX_CONSTEXPR unsigned long long
  1069. max() _GLIBCXX_USE_NOEXCEPT { return __LONG_LONG_MAX__ * 2ULL + 1; }
  1070. #if __cplusplus >= 201103L
  1071. static constexpr unsigned long long
  1072. lowest() noexcept { return min(); }
  1073. #endif
  1074. static _GLIBCXX_USE_CONSTEXPR int digits
  1075. = __glibcxx_digits (unsigned long long);
  1076. static _GLIBCXX_USE_CONSTEXPR int digits10
  1077. = __glibcxx_digits10 (unsigned long long);
  1078. #if __cplusplus >= 201103L
  1079. static constexpr int max_digits10 = 0;
  1080. #endif
  1081. static _GLIBCXX_USE_CONSTEXPR bool is_signed = false;
  1082. static _GLIBCXX_USE_CONSTEXPR bool is_integer = true;
  1083. static _GLIBCXX_USE_CONSTEXPR bool is_exact = true;
  1084. static _GLIBCXX_USE_CONSTEXPR int radix = 2;
  1085. static _GLIBCXX_CONSTEXPR unsigned long long
  1086. epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; }
  1087. static _GLIBCXX_CONSTEXPR unsigned long long
  1088. round_error() _GLIBCXX_USE_NOEXCEPT { return 0; }
  1089. static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0;
  1090. static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0;
  1091. static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0;
  1092. static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0;
  1093. static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false;
  1094. static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false;
  1095. static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false;
  1096. static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm
  1097. = denorm_absent;
  1098. static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false;
  1099. static _GLIBCXX_CONSTEXPR unsigned long long
  1100. infinity() _GLIBCXX_USE_NOEXCEPT
  1101. { return static_cast<unsigned long long>(0); }
  1102. static _GLIBCXX_CONSTEXPR unsigned long long
  1103. quiet_NaN() _GLIBCXX_USE_NOEXCEPT
  1104. { return static_cast<unsigned long long>(0); }
  1105. static _GLIBCXX_CONSTEXPR unsigned long long
  1106. signaling_NaN() _GLIBCXX_USE_NOEXCEPT
  1107. { return static_cast<unsigned long long>(0); }
  1108. static _GLIBCXX_CONSTEXPR unsigned long long
  1109. denorm_min() _GLIBCXX_USE_NOEXCEPT
  1110. { return static_cast<unsigned long long>(0); }
  1111. static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false;
  1112. static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true;
  1113. static _GLIBCXX_USE_CONSTEXPR bool is_modulo = true;
  1114. static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps;
  1115. static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false;
  1116. static _GLIBCXX_USE_CONSTEXPR float_round_style round_style
  1117. = round_toward_zero;
  1118. };
  1119. #if !defined(__STRICT_ANSI__)
  1120. #define __INT_N(TYPE, BITSIZE, EXT, UEXT) \
  1121. template<> \
  1122. struct numeric_limits<TYPE> \
  1123. { \
  1124. static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; \
  1125. \
  1126. static _GLIBCXX_CONSTEXPR TYPE \
  1127. min() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_min_b (TYPE, BITSIZE); } \
  1128. \
  1129. static _GLIBCXX_CONSTEXPR TYPE \
  1130. max() _GLIBCXX_USE_NOEXCEPT { return __glibcxx_max_b (TYPE, BITSIZE); } \
  1131. \
  1132. static _GLIBCXX_USE_CONSTEXPR int digits \
  1133. = BITSIZE - 1; \
  1134. static _GLIBCXX_USE_CONSTEXPR int digits10 \
  1135. = (BITSIZE - 1) * 643L / 2136; \
  1136. \
  1137. static _GLIBCXX_USE_CONSTEXPR bool is_signed = true; \
  1138. static _GLIBCXX_USE_CONSTEXPR bool is_integer = true; \
  1139. static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; \
  1140. static _GLIBCXX_USE_CONSTEXPR int radix = 2; \
  1141. \
  1142. static _GLIBCXX_CONSTEXPR TYPE \
  1143. epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } \
  1144. \
  1145. static _GLIBCXX_CONSTEXPR TYPE \
  1146. round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } \
  1147. \
  1148. EXT \
  1149. \
  1150. static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; \
  1151. static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0; \
  1152. static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0; \
  1153. static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0; \
  1154. \
  1155. static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; \
  1156. static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; \
  1157. static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; \
  1158. static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm \
  1159. = denorm_absent; \
  1160. static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; \
  1161. \
  1162. static _GLIBCXX_CONSTEXPR TYPE \
  1163. infinity() _GLIBCXX_USE_NOEXCEPT \
  1164. { return static_cast<TYPE>(0); } \
  1165. \
  1166. static _GLIBCXX_CONSTEXPR TYPE \
  1167. quiet_NaN() _GLIBCXX_USE_NOEXCEPT \
  1168. { return static_cast<TYPE>(0); } \
  1169. \
  1170. static _GLIBCXX_CONSTEXPR TYPE \
  1171. signaling_NaN() _GLIBCXX_USE_NOEXCEPT \
  1172. { return static_cast<TYPE>(0); } \
  1173. \
  1174. static _GLIBCXX_CONSTEXPR TYPE \
  1175. denorm_min() _GLIBCXX_USE_NOEXCEPT \
  1176. { return static_cast<TYPE>(0); } \
  1177. \
  1178. static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; \
  1179. static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; \
  1180. static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false; \
  1181. \
  1182. static _GLIBCXX_USE_CONSTEXPR bool traps \
  1183. = __glibcxx_integral_traps; \
  1184. static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; \
  1185. static _GLIBCXX_USE_CONSTEXPR float_round_style round_style \
  1186. = round_toward_zero; \
  1187. }; \
  1188. \
  1189. template<> \
  1190. struct numeric_limits<unsigned TYPE> \
  1191. { \
  1192. static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true; \
  1193. \
  1194. static _GLIBCXX_CONSTEXPR unsigned TYPE \
  1195. min() _GLIBCXX_USE_NOEXCEPT { return 0; } \
  1196. \
  1197. static _GLIBCXX_CONSTEXPR unsigned TYPE \
  1198. max() _GLIBCXX_USE_NOEXCEPT \
  1199. { return __glibcxx_max_b (unsigned TYPE, BITSIZE); } \
  1200. \
  1201. UEXT \
  1202. \
  1203. static _GLIBCXX_USE_CONSTEXPR int digits \
  1204. = BITSIZE; \
  1205. static _GLIBCXX_USE_CONSTEXPR int digits10 \
  1206. = BITSIZE * 643L / 2136; \
  1207. static _GLIBCXX_USE_CONSTEXPR bool is_signed = false; \
  1208. static _GLIBCXX_USE_CONSTEXPR bool is_integer = true; \
  1209. static _GLIBCXX_USE_CONSTEXPR bool is_exact = true; \
  1210. static _GLIBCXX_USE_CONSTEXPR int radix = 2; \
  1211. \
  1212. static _GLIBCXX_CONSTEXPR unsigned TYPE \
  1213. epsilon() _GLIBCXX_USE_NOEXCEPT { return 0; } \
  1214. \
  1215. static _GLIBCXX_CONSTEXPR unsigned TYPE \
  1216. round_error() _GLIBCXX_USE_NOEXCEPT { return 0; } \
  1217. \
  1218. static _GLIBCXX_USE_CONSTEXPR int min_exponent = 0; \
  1219. static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = 0; \
  1220. static _GLIBCXX_USE_CONSTEXPR int max_exponent = 0; \
  1221. static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = 0; \
  1222. \
  1223. static _GLIBCXX_USE_CONSTEXPR bool has_infinity = false; \
  1224. static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = false; \
  1225. static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = false; \
  1226. static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm \
  1227. = denorm_absent; \
  1228. static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss = false; \
  1229. \
  1230. static _GLIBCXX_CONSTEXPR unsigned TYPE \
  1231. infinity() _GLIBCXX_USE_NOEXCEPT \
  1232. { return static_cast<unsigned TYPE>(0); } \
  1233. \
  1234. static _GLIBCXX_CONSTEXPR unsigned TYPE \
  1235. quiet_NaN() _GLIBCXX_USE_NOEXCEPT \
  1236. { return static_cast<unsigned TYPE>(0); } \
  1237. \
  1238. static _GLIBCXX_CONSTEXPR unsigned TYPE \
  1239. signaling_NaN() _GLIBCXX_USE_NOEXCEPT \
  1240. { return static_cast<unsigned TYPE>(0); } \
  1241. \
  1242. static _GLIBCXX_CONSTEXPR unsigned TYPE \
  1243. denorm_min() _GLIBCXX_USE_NOEXCEPT \
  1244. { return static_cast<unsigned TYPE>(0); } \
  1245. \
  1246. static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false; \
  1247. static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true; \
  1248. static _GLIBCXX_USE_CONSTEXPR bool is_modulo = true; \
  1249. \
  1250. static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps; \
  1251. static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false; \
  1252. static _GLIBCXX_USE_CONSTEXPR float_round_style round_style \
  1253. = round_toward_zero; \
  1254. };
  1255. #if __cplusplus >= 201103L
  1256. #define __INT_N_201103(TYPE) \
  1257. static constexpr TYPE \
  1258. lowest() noexcept { return min(); } \
  1259. static constexpr int max_digits10 = 0;
  1260. #define __INT_N_U201103(TYPE) \
  1261. static constexpr unsigned TYPE \
  1262. lowest() noexcept { return min(); } \
  1263. static constexpr int max_digits10 = 0;
  1264. #else
  1265. #define __INT_N_201103(TYPE)
  1266. #define __INT_N_U201103(TYPE)
  1267. #endif
  1268. #ifdef __GLIBCXX_TYPE_INT_N_0
  1269. __INT_N(__GLIBCXX_TYPE_INT_N_0, __GLIBCXX_BITSIZE_INT_N_0,
  1270. __INT_N_201103 (__GLIBCXX_TYPE_INT_N_0), __INT_N_U201103 (__GLIBCXX_TYPE_INT_N_0))
  1271. #endif
  1272. #ifdef __GLIBCXX_TYPE_INT_N_1
  1273. __INT_N (__GLIBCXX_TYPE_INT_N_1, __GLIBCXX_BITSIZE_INT_N_1,
  1274. __INT_N_201103 (__GLIBCXX_TYPE_INT_N_1), __INT_N_U201103 (__GLIBCXX_TYPE_INT_N_1))
  1275. #endif
  1276. #ifdef __GLIBCXX_TYPE_INT_N_2
  1277. __INT_N (__GLIBCXX_TYPE_INT_N_2, __GLIBCXX_BITSIZE_INT_N_2,
  1278. __INT_N_201103 (__GLIBCXX_TYPE_INT_N_2), __INT_N_U201103 (__GLIBCXX_TYPE_INT_N_2))
  1279. #endif
  1280. #ifdef __GLIBCXX_TYPE_INT_N_3
  1281. __INT_N (__GLIBCXX_TYPE_INT_N_3, __GLIBCXX_BITSIZE_INT_N_3,
  1282. __INT_N_201103 (__GLIBCXX_TYPE_INT_N_3), __INT_N_U201103 (__GLIBCXX_TYPE_INT_N_3))
  1283. #endif
  1284. #undef __INT_N
  1285. #undef __INT_N_201103
  1286. #undef __INT_N_U201103
  1287. #endif
  1288. /// numeric_limits<float> specialization.
  1289. template<>
  1290. struct numeric_limits<float>
  1291. {
  1292. static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true;
  1293. static _GLIBCXX_CONSTEXPR float
  1294. min() _GLIBCXX_USE_NOEXCEPT { return __FLT_MIN__; }
  1295. static _GLIBCXX_CONSTEXPR float
  1296. max() _GLIBCXX_USE_NOEXCEPT { return __FLT_MAX__; }
  1297. #if __cplusplus >= 201103L
  1298. static constexpr float
  1299. lowest() noexcept { return -__FLT_MAX__; }
  1300. #endif
  1301. static _GLIBCXX_USE_CONSTEXPR int digits = __FLT_MANT_DIG__;
  1302. static _GLIBCXX_USE_CONSTEXPR int digits10 = __FLT_DIG__;
  1303. #if __cplusplus >= 201103L
  1304. static constexpr int max_digits10
  1305. = __glibcxx_max_digits10 (__FLT_MANT_DIG__);
  1306. #endif
  1307. static _GLIBCXX_USE_CONSTEXPR bool is_signed = true;
  1308. static _GLIBCXX_USE_CONSTEXPR bool is_integer = false;
  1309. static _GLIBCXX_USE_CONSTEXPR bool is_exact = false;
  1310. static _GLIBCXX_USE_CONSTEXPR int radix = __FLT_RADIX__;
  1311. static _GLIBCXX_CONSTEXPR float
  1312. epsilon() _GLIBCXX_USE_NOEXCEPT { return __FLT_EPSILON__; }
  1313. static _GLIBCXX_CONSTEXPR float
  1314. round_error() _GLIBCXX_USE_NOEXCEPT { return 0.5F; }
  1315. static _GLIBCXX_USE_CONSTEXPR int min_exponent = __FLT_MIN_EXP__;
  1316. static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = __FLT_MIN_10_EXP__;
  1317. static _GLIBCXX_USE_CONSTEXPR int max_exponent = __FLT_MAX_EXP__;
  1318. static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = __FLT_MAX_10_EXP__;
  1319. static _GLIBCXX_USE_CONSTEXPR bool has_infinity = __FLT_HAS_INFINITY__;
  1320. static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = __FLT_HAS_QUIET_NAN__;
  1321. static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = has_quiet_NaN;
  1322. static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm
  1323. = bool(__FLT_HAS_DENORM__) ? denorm_present : denorm_absent;
  1324. static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss
  1325. = __glibcxx_float_has_denorm_loss;
  1326. static _GLIBCXX_CONSTEXPR float
  1327. infinity() _GLIBCXX_USE_NOEXCEPT { return __builtin_huge_valf(); }
  1328. static _GLIBCXX_CONSTEXPR float
  1329. quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return __builtin_nanf(""); }
  1330. static _GLIBCXX_CONSTEXPR float
  1331. signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return __builtin_nansf(""); }
  1332. static _GLIBCXX_CONSTEXPR float
  1333. denorm_min() _GLIBCXX_USE_NOEXCEPT { return __FLT_DENORM_MIN__; }
  1334. static _GLIBCXX_USE_CONSTEXPR bool is_iec559
  1335. = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
  1336. static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true;
  1337. static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false;
  1338. static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_float_traps;
  1339. static _GLIBCXX_USE_CONSTEXPR bool tinyness_before
  1340. = __glibcxx_float_tinyness_before;
  1341. static _GLIBCXX_USE_CONSTEXPR float_round_style round_style
  1342. = round_to_nearest;
  1343. };
  1344. #undef __glibcxx_float_has_denorm_loss
  1345. #undef __glibcxx_float_traps
  1346. #undef __glibcxx_float_tinyness_before
  1347. /// numeric_limits<double> specialization.
  1348. template<>
  1349. struct numeric_limits<double>
  1350. {
  1351. static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true;
  1352. static _GLIBCXX_CONSTEXPR double
  1353. min() _GLIBCXX_USE_NOEXCEPT { return __DBL_MIN__; }
  1354. static _GLIBCXX_CONSTEXPR double
  1355. max() _GLIBCXX_USE_NOEXCEPT { return __DBL_MAX__; }
  1356. #if __cplusplus >= 201103L
  1357. static constexpr double
  1358. lowest() noexcept { return -__DBL_MAX__; }
  1359. #endif
  1360. static _GLIBCXX_USE_CONSTEXPR int digits = __DBL_MANT_DIG__;
  1361. static _GLIBCXX_USE_CONSTEXPR int digits10 = __DBL_DIG__;
  1362. #if __cplusplus >= 201103L
  1363. static constexpr int max_digits10
  1364. = __glibcxx_max_digits10 (__DBL_MANT_DIG__);
  1365. #endif
  1366. static _GLIBCXX_USE_CONSTEXPR bool is_signed = true;
  1367. static _GLIBCXX_USE_CONSTEXPR bool is_integer = false;
  1368. static _GLIBCXX_USE_CONSTEXPR bool is_exact = false;
  1369. static _GLIBCXX_USE_CONSTEXPR int radix = __FLT_RADIX__;
  1370. static _GLIBCXX_CONSTEXPR double
  1371. epsilon() _GLIBCXX_USE_NOEXCEPT { return __DBL_EPSILON__; }
  1372. static _GLIBCXX_CONSTEXPR double
  1373. round_error() _GLIBCXX_USE_NOEXCEPT { return 0.5; }
  1374. static _GLIBCXX_USE_CONSTEXPR int min_exponent = __DBL_MIN_EXP__;
  1375. static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = __DBL_MIN_10_EXP__;
  1376. static _GLIBCXX_USE_CONSTEXPR int max_exponent = __DBL_MAX_EXP__;
  1377. static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = __DBL_MAX_10_EXP__;
  1378. static _GLIBCXX_USE_CONSTEXPR bool has_infinity = __DBL_HAS_INFINITY__;
  1379. static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = __DBL_HAS_QUIET_NAN__;
  1380. static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = has_quiet_NaN;
  1381. static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm
  1382. = bool(__DBL_HAS_DENORM__) ? denorm_present : denorm_absent;
  1383. static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss
  1384. = __glibcxx_double_has_denorm_loss;
  1385. static _GLIBCXX_CONSTEXPR double
  1386. infinity() _GLIBCXX_USE_NOEXCEPT { return __builtin_huge_val(); }
  1387. static _GLIBCXX_CONSTEXPR double
  1388. quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return __builtin_nan(""); }
  1389. static _GLIBCXX_CONSTEXPR double
  1390. signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return __builtin_nans(""); }
  1391. static _GLIBCXX_CONSTEXPR double
  1392. denorm_min() _GLIBCXX_USE_NOEXCEPT { return __DBL_DENORM_MIN__; }
  1393. static _GLIBCXX_USE_CONSTEXPR bool is_iec559
  1394. = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
  1395. static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true;
  1396. static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false;
  1397. static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_double_traps;
  1398. static _GLIBCXX_USE_CONSTEXPR bool tinyness_before
  1399. = __glibcxx_double_tinyness_before;
  1400. static _GLIBCXX_USE_CONSTEXPR float_round_style round_style
  1401. = round_to_nearest;
  1402. };
  1403. #undef __glibcxx_double_has_denorm_loss
  1404. #undef __glibcxx_double_traps
  1405. #undef __glibcxx_double_tinyness_before
  1406. /// numeric_limits<long double> specialization.
  1407. template<>
  1408. struct numeric_limits<long double>
  1409. {
  1410. static _GLIBCXX_USE_CONSTEXPR bool is_specialized = true;
  1411. static _GLIBCXX_CONSTEXPR long double
  1412. min() _GLIBCXX_USE_NOEXCEPT { return __LDBL_MIN__; }
  1413. static _GLIBCXX_CONSTEXPR long double
  1414. max() _GLIBCXX_USE_NOEXCEPT { return __LDBL_MAX__; }
  1415. #if __cplusplus >= 201103L
  1416. static constexpr long double
  1417. lowest() noexcept { return -__LDBL_MAX__; }
  1418. #endif
  1419. static _GLIBCXX_USE_CONSTEXPR int digits = __LDBL_MANT_DIG__;
  1420. static _GLIBCXX_USE_CONSTEXPR int digits10 = __LDBL_DIG__;
  1421. #if __cplusplus >= 201103L
  1422. static _GLIBCXX_USE_CONSTEXPR int max_digits10
  1423. = __glibcxx_max_digits10 (__LDBL_MANT_DIG__);
  1424. #endif
  1425. static _GLIBCXX_USE_CONSTEXPR bool is_signed = true;
  1426. static _GLIBCXX_USE_CONSTEXPR bool is_integer = false;
  1427. static _GLIBCXX_USE_CONSTEXPR bool is_exact = false;
  1428. static _GLIBCXX_USE_CONSTEXPR int radix = __FLT_RADIX__;
  1429. static _GLIBCXX_CONSTEXPR long double
  1430. epsilon() _GLIBCXX_USE_NOEXCEPT { return __LDBL_EPSILON__; }
  1431. static _GLIBCXX_CONSTEXPR long double
  1432. round_error() _GLIBCXX_USE_NOEXCEPT { return 0.5L; }
  1433. static _GLIBCXX_USE_CONSTEXPR int min_exponent = __LDBL_MIN_EXP__;
  1434. static _GLIBCXX_USE_CONSTEXPR int min_exponent10 = __LDBL_MIN_10_EXP__;
  1435. static _GLIBCXX_USE_CONSTEXPR int max_exponent = __LDBL_MAX_EXP__;
  1436. static _GLIBCXX_USE_CONSTEXPR int max_exponent10 = __LDBL_MAX_10_EXP__;
  1437. static _GLIBCXX_USE_CONSTEXPR bool has_infinity = __LDBL_HAS_INFINITY__;
  1438. static _GLIBCXX_USE_CONSTEXPR bool has_quiet_NaN = __LDBL_HAS_QUIET_NAN__;
  1439. static _GLIBCXX_USE_CONSTEXPR bool has_signaling_NaN = has_quiet_NaN;
  1440. static _GLIBCXX_USE_CONSTEXPR float_denorm_style has_denorm
  1441. = bool(__LDBL_HAS_DENORM__) ? denorm_present : denorm_absent;
  1442. static _GLIBCXX_USE_CONSTEXPR bool has_denorm_loss
  1443. = __glibcxx_long_double_has_denorm_loss;
  1444. static _GLIBCXX_CONSTEXPR long double
  1445. infinity() _GLIBCXX_USE_NOEXCEPT { return __builtin_huge_vall(); }
  1446. static _GLIBCXX_CONSTEXPR long double
  1447. quiet_NaN() _GLIBCXX_USE_NOEXCEPT { return __builtin_nanl(""); }
  1448. static _GLIBCXX_CONSTEXPR long double
  1449. signaling_NaN() _GLIBCXX_USE_NOEXCEPT { return __builtin_nansl(""); }
  1450. static _GLIBCXX_CONSTEXPR long double
  1451. denorm_min() _GLIBCXX_USE_NOEXCEPT { return __LDBL_DENORM_MIN__; }
  1452. static _GLIBCXX_USE_CONSTEXPR bool is_iec559
  1453. = has_infinity && has_quiet_NaN && has_denorm == denorm_present;
  1454. static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true;
  1455. static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false;
  1456. static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_long_double_traps;
  1457. static _GLIBCXX_USE_CONSTEXPR bool tinyness_before =
  1458. __glibcxx_long_double_tinyness_before;
  1459. static _GLIBCXX_USE_CONSTEXPR float_round_style round_style =
  1460. round_to_nearest;
  1461. };
  1462. #undef __glibcxx_long_double_has_denorm_loss
  1463. #undef __glibcxx_long_double_traps
  1464. #undef __glibcxx_long_double_tinyness_before
  1465. _GLIBCXX_END_NAMESPACE_VERSION
  1466. } // namespace
  1467. #undef __glibcxx_signed
  1468. #undef __glibcxx_min
  1469. #undef __glibcxx_max
  1470. #undef __glibcxx_digits
  1471. #undef __glibcxx_digits10
  1472. #undef __glibcxx_max_digits10
  1473. #endif // _GLIBCXX_NUMERIC_LIMITS