_limits.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  1. /*
  2. * Copyright (c) 1997
  3. * Silicon Graphics Computer Systems, Inc.
  4. *
  5. * Copyright (c) 1999
  6. * Boris Fomitchev
  7. *
  8. * This material is provided "as is", with absolutely no warranty expressed
  9. * or implied. Any use is at your own risk.
  10. *
  11. * Permission to use or copy this software for any purpose is hereby granted
  12. * without fee, provided the above notices are retained on all copies.
  13. * Permission to modify the code and to distribute modified code is granted,
  14. * provided the above notices are retained, and a notice that the code was
  15. * modified is included with the above copyright notice.
  16. *
  17. */
  18. /* NOTE: This may be not portable code. Parts of numeric_limits<> are
  19. * inherently machine-dependent. At present this file is suitable
  20. * for the MIPS, SPARC, Alpha and ia32 architectures.
  21. */
  22. #ifndef _STLP_INTERNAL_LIMITS
  23. #define _STLP_INTERNAL_LIMITS
  24. #ifndef _STLP_CLIMITS
  25. # include <climits>
  26. #endif
  27. #ifndef _STLP_CFLOAT
  28. # include <cfloat>
  29. #endif
  30. #if defined (_STLP_HAS_WCHAR_T) && !defined (_STLP_INTERNAL_CWCHAR)
  31. # include <stl/_cwchar.h>
  32. #endif
  33. _STLP_BEGIN_NAMESPACE
  34. enum float_round_style {
  35. round_indeterminate = -1,
  36. round_toward_zero = 0,
  37. round_to_nearest = 1,
  38. round_toward_infinity = 2,
  39. round_toward_neg_infinity = 3
  40. };
  41. enum float_denorm_style {
  42. denorm_indeterminate = -1,
  43. denorm_absent = 0,
  44. denorm_present = 1
  45. };
  46. _STLP_MOVE_TO_PRIV_NAMESPACE
  47. // Base class for all specializations of numeric_limits.
  48. template <class __number>
  49. class _Numeric_limits_base {
  50. public:
  51. static __number (_STLP_CALL min)() _STLP_NOTHROW { return __number(); }
  52. static __number (_STLP_CALL max)() _STLP_NOTHROW { return __number(); }
  53. _STLP_STATIC_CONSTANT(int, digits = 0);
  54. _STLP_STATIC_CONSTANT(int, digits10 = 0);
  55. _STLP_STATIC_CONSTANT(int, radix = 0);
  56. _STLP_STATIC_CONSTANT(int, min_exponent = 0);
  57. _STLP_STATIC_CONSTANT(int, min_exponent10 = 0);
  58. _STLP_STATIC_CONSTANT(int, max_exponent = 0);
  59. _STLP_STATIC_CONSTANT(int, max_exponent10 = 0);
  60. _STLP_STATIC_CONSTANT(float_denorm_style, has_denorm = denorm_absent);
  61. _STLP_STATIC_CONSTANT(float_round_style, round_style = round_toward_zero);
  62. _STLP_STATIC_CONSTANT(bool, is_specialized = false);
  63. _STLP_STATIC_CONSTANT(bool, is_signed = false);
  64. _STLP_STATIC_CONSTANT(bool, is_integer = false);
  65. _STLP_STATIC_CONSTANT(bool, is_exact = false);
  66. _STLP_STATIC_CONSTANT(bool, has_infinity = false);
  67. _STLP_STATIC_CONSTANT(bool, has_quiet_NaN = false);
  68. _STLP_STATIC_CONSTANT(bool, has_signaling_NaN = false);
  69. _STLP_STATIC_CONSTANT(bool, has_denorm_loss = false);
  70. _STLP_STATIC_CONSTANT(bool, is_iec559 = false);
  71. _STLP_STATIC_CONSTANT(bool, is_bounded = false);
  72. _STLP_STATIC_CONSTANT(bool, is_modulo = false);
  73. _STLP_STATIC_CONSTANT(bool, traps = false);
  74. _STLP_STATIC_CONSTANT(bool, tinyness_before = false);
  75. static __number _STLP_CALL epsilon() _STLP_NOTHROW { return __number(); }
  76. static __number _STLP_CALL round_error() _STLP_NOTHROW { return __number(); }
  77. static __number _STLP_CALL infinity() _STLP_NOTHROW { return __number(); }
  78. static __number _STLP_CALL quiet_NaN() _STLP_NOTHROW { return __number(); }
  79. static __number _STLP_CALL signaling_NaN() _STLP_NOTHROW { return __number(); }
  80. static __number _STLP_CALL denorm_min() _STLP_NOTHROW { return __number(); }
  81. };
  82. // Base class for integers.
  83. #ifdef _STLP_LIMITED_DEFAULT_TEMPLATES
  84. # ifdef _STLP_LONG_LONG
  85. # define _STLP_LIMITS_MIN_TYPE _STLP_LONG_LONG
  86. # define _STLP_LIMITS_MAX_TYPE unsigned _STLP_LONG_LONG
  87. # else
  88. # define _STLP_LIMITS_MIN_TYPE long
  89. # define _STLP_LIMITS_MAX_TYPE unsigned long
  90. # endif
  91. #else
  92. # define _STLP_LIMITS_MIN_TYPE _Int
  93. # define _STLP_LIMITS_MAX_TYPE _Int
  94. #endif /* _STLP_LIMITED_DEFAULT_TEMPLATES */
  95. template <class _Int,
  96. _STLP_LIMITS_MIN_TYPE __imin,
  97. _STLP_LIMITS_MAX_TYPE __imax,
  98. int __idigits, bool __ismod>
  99. class _Integer_limits : public _Numeric_limits_base<_Int> {
  100. public:
  101. static _Int (_STLP_CALL min) () _STLP_NOTHROW { return (_Int)__imin; }
  102. static _Int (_STLP_CALL max) () _STLP_NOTHROW { return (_Int)__imax; }
  103. _STLP_STATIC_CONSTANT(int, digits = (__idigits < 0) ? ((int)((sizeof(_Int) * (CHAR_BIT))) - ((__imin == 0) ? 0 : 1)) : (__idigits));
  104. _STLP_STATIC_CONSTANT(int, digits10 = (digits * 301UL) / 1000);
  105. _STLP_STATIC_CONSTANT(int, radix = 2);
  106. _STLP_STATIC_CONSTANT(bool, is_specialized = true);
  107. _STLP_STATIC_CONSTANT(bool, is_signed = (__imin != 0));
  108. _STLP_STATIC_CONSTANT(bool, is_integer = true);
  109. _STLP_STATIC_CONSTANT(bool, is_exact = true);
  110. _STLP_STATIC_CONSTANT(bool, is_bounded = true);
  111. _STLP_STATIC_CONSTANT(bool, is_modulo = __ismod);
  112. };
  113. // Base class for floating-point numbers.
  114. template <class __number,
  115. int __Digits, int __Digits10,
  116. int __MinExp, int __MaxExp,
  117. int __MinExp10, int __MaxExp10,
  118. bool __IsIEC559,
  119. float_denorm_style __DenormStyle,
  120. float_round_style __RoundStyle>
  121. class _Floating_limits : public _Numeric_limits_base<__number> {
  122. public:
  123. _STLP_STATIC_CONSTANT(int, digits = __Digits);
  124. _STLP_STATIC_CONSTANT(int, digits10 = __Digits10);
  125. _STLP_STATIC_CONSTANT(int, radix = FLT_RADIX);
  126. _STLP_STATIC_CONSTANT(int, min_exponent = __MinExp);
  127. _STLP_STATIC_CONSTANT(int, max_exponent = __MaxExp);
  128. _STLP_STATIC_CONSTANT(int, min_exponent10 = __MinExp10);
  129. _STLP_STATIC_CONSTANT(int, max_exponent10 = __MaxExp10);
  130. _STLP_STATIC_CONSTANT(float_denorm_style, has_denorm = __DenormStyle);
  131. _STLP_STATIC_CONSTANT(float_round_style, round_style = __RoundStyle);
  132. _STLP_STATIC_CONSTANT(bool, is_specialized = true);
  133. _STLP_STATIC_CONSTANT(bool, is_signed = true);
  134. _STLP_STATIC_CONSTANT(bool, has_infinity = true);
  135. #if (!defined (_STLP_MSVC) || (_STLP_MSVC > 1300)) && \
  136. (!defined (__BORLANDC__) || (__BORLANDC__ >= 0x590)) && \
  137. (!defined (_CRAY) || defined (_CRAYIEEE))
  138. _STLP_STATIC_CONSTANT(bool, has_quiet_NaN = true);
  139. _STLP_STATIC_CONSTANT(bool, has_signaling_NaN = true);
  140. #else
  141. _STLP_STATIC_CONSTANT(bool, has_quiet_NaN = false);
  142. _STLP_STATIC_CONSTANT(bool, has_signaling_NaN = false);
  143. #endif
  144. _STLP_STATIC_CONSTANT(bool, is_iec559 = __IsIEC559 && has_infinity && has_quiet_NaN && has_signaling_NaN && (has_denorm == denorm_present));
  145. _STLP_STATIC_CONSTANT(bool, has_denorm_loss = false);
  146. _STLP_STATIC_CONSTANT(bool, is_bounded = true);
  147. _STLP_STATIC_CONSTANT(bool, traps = true);
  148. _STLP_STATIC_CONSTANT(bool, tinyness_before = false);
  149. };
  150. _STLP_MOVE_TO_STD_NAMESPACE
  151. // Class numeric_limits
  152. // The unspecialized class.
  153. template<class _Tp>
  154. class numeric_limits : public _STLP_PRIV _Numeric_limits_base<_Tp> {};
  155. // Specializations for all built-in integral types.
  156. #if !defined (_STLP_NO_BOOL)
  157. _STLP_TEMPLATE_NULL
  158. class numeric_limits<bool>
  159. : public _STLP_PRIV _Integer_limits<bool, false, true, 1, false>
  160. {};
  161. #endif /* _STLP_NO_BOOL */
  162. _STLP_TEMPLATE_NULL
  163. class numeric_limits<char>
  164. : public _STLP_PRIV _Integer_limits<char, CHAR_MIN, CHAR_MAX, -1, true>
  165. {};
  166. #if !defined (_STLP_NO_SIGNED_BUILTINS)
  167. _STLP_TEMPLATE_NULL
  168. class numeric_limits<signed char>
  169. : public _STLP_PRIV _Integer_limits<signed char, SCHAR_MIN, SCHAR_MAX, -1, true>
  170. {};
  171. #endif
  172. _STLP_TEMPLATE_NULL
  173. class numeric_limits<unsigned char>
  174. : public _STLP_PRIV _Integer_limits<unsigned char, 0, UCHAR_MAX, -1, true>
  175. {};
  176. #if !(defined (_STLP_NO_WCHAR_T) || (!defined (_STLP_SGX_CONFIG) && defined (_STLP_WCHAR_T_IS_USHORT)))
  177. _STLP_TEMPLATE_NULL
  178. class numeric_limits<wchar_t>
  179. : public _STLP_PRIV _Integer_limits<wchar_t, WCHAR_MIN, WCHAR_MAX, -1, true>
  180. {};
  181. #endif
  182. _STLP_TEMPLATE_NULL
  183. class numeric_limits<short>
  184. : public _STLP_PRIV _Integer_limits<short, SHRT_MIN, SHRT_MAX, -1, true>
  185. {};
  186. _STLP_TEMPLATE_NULL
  187. class numeric_limits<unsigned short>
  188. : public _STLP_PRIV _Integer_limits<unsigned short, 0, USHRT_MAX, -1, true>
  189. {};
  190. #if defined (__xlC__) && (__xlC__ == 0x500)
  191. # undef INT_MIN
  192. # define INT_MIN -2147483648
  193. #endif
  194. _STLP_TEMPLATE_NULL
  195. class numeric_limits<int>
  196. : public _STLP_PRIV _Integer_limits<int, INT_MIN, INT_MAX, -1, true>
  197. {};
  198. _STLP_TEMPLATE_NULL
  199. class numeric_limits<unsigned int>
  200. : public _STLP_PRIV _Integer_limits<unsigned int, 0, UINT_MAX, -1, true>
  201. {};
  202. _STLP_TEMPLATE_NULL
  203. class numeric_limits<long>
  204. : public _STLP_PRIV _Integer_limits<long, LONG_MIN, LONG_MAX, -1, true>
  205. {};
  206. _STLP_TEMPLATE_NULL
  207. class numeric_limits<unsigned long>
  208. : public _STLP_PRIV _Integer_limits<unsigned long, 0, ULONG_MAX, -1, true>
  209. {};
  210. #if defined (_STLP_LONG_LONG)
  211. # if defined (_STLP_MSVC) || defined (__BORLANDC__)
  212. # define LONGLONG_MAX 0x7fffffffffffffffi64
  213. # define LONGLONG_MIN (-LONGLONG_MAX-1i64)
  214. # define ULONGLONG_MAX 0xffffffffffffffffUi64
  215. # else
  216. # ifndef LONGLONG_MAX
  217. # define LONGLONG_MAX 0x7fffffffffffffffLL
  218. # endif
  219. # ifndef LONGLONG_MIN
  220. # define LONGLONG_MIN (-LONGLONG_MAX-1LL)
  221. # endif
  222. # ifndef ULONGLONG_MAX
  223. # define ULONGLONG_MAX 0xffffffffffffffffULL
  224. # endif
  225. # endif
  226. # if !defined (__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ <= 96) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 3)
  227. _STLP_TEMPLATE_NULL
  228. class numeric_limits<_STLP_LONG_LONG>
  229. : public _STLP_PRIV _Integer_limits<_STLP_LONG_LONG, LONGLONG_MIN, LONGLONG_MAX, -1, true>
  230. {};
  231. _STLP_TEMPLATE_NULL
  232. class numeric_limits<unsigned _STLP_LONG_LONG>
  233. : public _STLP_PRIV _Integer_limits<unsigned _STLP_LONG_LONG, 0, ULONGLONG_MAX, -1, true>
  234. {};
  235. # else /* gcc 2.97 (after 2000-11-01), 2.98, 3.0 */
  236. /*
  237. newest gcc has new mangling scheme, that has problem
  238. with generating name [instantiated] of template specialization like
  239. _Integer_limits<_STLP_LONG_LONG, LONGLONG_MIN, LONGLONG_MAX, -1, true>
  240. ~~~~~~~~~~~~ ~~~~~~~~~~~~
  241. Below is code that solve this problem.
  242. - ptr
  243. */
  244. _STLP_TEMPLATE_NULL
  245. class numeric_limits<_STLP_LONG_LONG>
  246. : public _STLP_PRIV _Numeric_limits_base<_STLP_LONG_LONG> {
  247. public:
  248. static _STLP_LONG_LONG (_STLP_CALL min) () _STLP_NOTHROW { return LONGLONG_MIN; }
  249. static _STLP_LONG_LONG (_STLP_CALL max) () _STLP_NOTHROW { return LONGLONG_MAX; }
  250. _STLP_STATIC_CONSTANT(int, digits = ((int)((sizeof(_STLP_LONG_LONG) * (CHAR_BIT))) - 1));
  251. _STLP_STATIC_CONSTANT(int, digits10 = (digits * 301UL) / 1000);
  252. _STLP_STATIC_CONSTANT(int, radix = 2);
  253. _STLP_STATIC_CONSTANT(bool, is_specialized = true);
  254. _STLP_STATIC_CONSTANT(bool, is_signed = true);
  255. _STLP_STATIC_CONSTANT(bool, is_integer = true);
  256. _STLP_STATIC_CONSTANT(bool, is_exact = true);
  257. _STLP_STATIC_CONSTANT(bool, is_bounded = true);
  258. _STLP_STATIC_CONSTANT(bool, is_modulo = true);
  259. };
  260. _STLP_TEMPLATE_NULL
  261. class numeric_limits<unsigned _STLP_LONG_LONG>
  262. : public _STLP_PRIV _Numeric_limits_base<unsigned _STLP_LONG_LONG> {
  263. public:
  264. static unsigned _STLP_LONG_LONG (_STLP_CALL min) () _STLP_NOTHROW { return 0ULL; }
  265. static unsigned _STLP_LONG_LONG (_STLP_CALL max) () _STLP_NOTHROW { return ULONGLONG_MAX; }
  266. _STLP_STATIC_CONSTANT(int, digits = ((int)((sizeof(unsigned _STLP_LONG_LONG) * (CHAR_BIT)))));
  267. _STLP_STATIC_CONSTANT(int, digits10 = (digits * 301UL) / 1000);
  268. _STLP_STATIC_CONSTANT(int, radix = 2);
  269. _STLP_STATIC_CONSTANT(bool, is_specialized = true);
  270. _STLP_STATIC_CONSTANT(bool, is_signed = false);
  271. _STLP_STATIC_CONSTANT(bool, is_integer = true);
  272. _STLP_STATIC_CONSTANT(bool, is_exact = true);
  273. _STLP_STATIC_CONSTANT(bool, is_bounded = true);
  274. _STLP_STATIC_CONSTANT(bool, is_modulo = true);
  275. };
  276. # endif /* __GNUC__ > 2000-11-01 */
  277. #endif /* _STLP_LONG_LONG */
  278. _STLP_MOVE_TO_PRIV_NAMESPACE
  279. // Specializations for all built-in floating-point types.
  280. template <class __dummy>
  281. class _LimG {
  282. public:
  283. static float _STLP_CALL get_F_inf();
  284. static float _STLP_CALL get_F_qNaN();
  285. static float _STLP_CALL get_F_sNaN();
  286. static float _STLP_CALL get_F_denormMin();
  287. static double _STLP_CALL get_D_inf();
  288. static double _STLP_CALL get_D_qNaN();
  289. static double _STLP_CALL get_D_sNaN();
  290. static double _STLP_CALL get_D_denormMin();
  291. #if !defined (_STLP_NO_LONG_DOUBLE)
  292. static long double _STLP_CALL get_LD_inf();
  293. static long double _STLP_CALL get_LD_qNaN();
  294. static long double _STLP_CALL get_LD_sNaN();
  295. static long double _STLP_CALL get_LD_denormMin();
  296. #endif
  297. };
  298. #if defined (_STLP_USE_TEMPLATE_EXPORT)
  299. _STLP_EXPORT_TEMPLATE_CLASS _LimG<bool>;
  300. #endif
  301. #if defined (__GNUC__)
  302. # if defined (__FLT_DENORM_MIN__)
  303. # define _STLP_FLT_DENORM_MIN __FLT_DENORM_MIN__
  304. # else
  305. # define _STLP_FLT_DENORM_STYLE denorm_absent
  306. # endif
  307. # if defined (__DBL_DENORM_MIN__)
  308. # define _STLP_DBL_DENORM_MIN __DBL_DENORM_MIN__
  309. # else
  310. # define _STLP_DBL_DENORM_STYLE denorm_absent
  311. # endif
  312. # if defined (__LDBL_DENORM_MIN__)
  313. # define _STLP_LDBL_DENORM_MIN __LDBL_DENORM_MIN__
  314. # else
  315. # define _STLP_LDBL_DENORM_STYLE denorm_absent
  316. # endif
  317. #endif
  318. /* If compiler do not expose thanks to some macro its status regarding
  319. * denormalized floating point numbers, we consider that denormalization
  320. * is present. Unit tests will tell us if compiler do not support them. */
  321. #if !defined (_STLP_FLT_DENORM_STYLE)
  322. # define _STLP_FLT_DENORM_STYLE denorm_present
  323. #endif
  324. #if !defined (_STLP_DBL_DENORM_STYLE)
  325. # define _STLP_DBL_DENORM_STYLE denorm_present
  326. #endif
  327. #if !defined (_STLP_LDBL_DENORM_STYLE)
  328. # define _STLP_LDBL_DENORM_STYLE denorm_present
  329. #endif
  330. _STLP_MOVE_TO_STD_NAMESPACE
  331. _STLP_TEMPLATE_NULL
  332. class numeric_limits<float>
  333. : public _STLP_PRIV _Floating_limits<float,
  334. FLT_MANT_DIG, // Binary digits of precision
  335. FLT_DIG, // Decimal digits of precision
  336. FLT_MIN_EXP, // Minimum exponent
  337. FLT_MAX_EXP, // Maximum exponent
  338. FLT_MIN_10_EXP, // Minimum base 10 exponent
  339. FLT_MAX_10_EXP, // Maximum base 10 exponent
  340. true,
  341. _STLP_FLT_DENORM_STYLE,
  342. round_to_nearest> {
  343. public:
  344. static float (_STLP_CALL min) () _STLP_NOTHROW { return FLT_MIN; }
  345. static float _STLP_CALL denorm_min() _STLP_NOTHROW
  346. #if defined (_STLP_FLT_DENORM_MIN)
  347. { return _STLP_FLT_DENORM_MIN; }
  348. #else
  349. { return _STLP_FLT_DENORM_STYLE ? _STLP_PRIV _LimG<bool>::get_F_denormMin() : FLT_MIN; }
  350. #endif
  351. static float (_STLP_CALL max) () _STLP_NOTHROW { return FLT_MAX; }
  352. static float _STLP_CALL epsilon() _STLP_NOTHROW { return FLT_EPSILON; }
  353. static float _STLP_CALL round_error() _STLP_NOTHROW { return 0.5f; } // Units: ulps.
  354. static float _STLP_CALL infinity() _STLP_NOTHROW { return _STLP_PRIV _LimG<bool>::get_F_inf(); }
  355. static float _STLP_CALL quiet_NaN() _STLP_NOTHROW { return _STLP_PRIV _LimG<bool>::get_F_qNaN(); }
  356. static float _STLP_CALL signaling_NaN() _STLP_NOTHROW { return _STLP_PRIV _LimG<bool>::get_F_sNaN(); }
  357. };
  358. #undef _STLP_FLT_DENORM_MIN
  359. #undef _STLP_FLT_DNORM_STYLE
  360. _STLP_TEMPLATE_NULL
  361. class numeric_limits<double>
  362. : public _STLP_PRIV _Floating_limits<double,
  363. DBL_MANT_DIG, // Binary digits of precision
  364. DBL_DIG, // Decimal digits of precision
  365. DBL_MIN_EXP, // Minimum exponent
  366. DBL_MAX_EXP, // Maximum exponent
  367. DBL_MIN_10_EXP, // Minimum base 10 exponent
  368. DBL_MAX_10_EXP, // Maximum base 10 exponent
  369. true,
  370. _STLP_DBL_DENORM_STYLE,
  371. round_to_nearest> {
  372. public:
  373. static double (_STLP_CALL min)() _STLP_NOTHROW { return DBL_MIN; }
  374. static double _STLP_CALL denorm_min() _STLP_NOTHROW
  375. #if defined (_STLP_DBL_DENORM_MIN)
  376. { return _STLP_DBL_DENORM_MIN; }
  377. #else
  378. { return _STLP_DBL_DENORM_STYLE ? _STLP_PRIV _LimG<bool>::get_D_denormMin() : DBL_MIN; }
  379. #endif
  380. static double (_STLP_CALL max)() _STLP_NOTHROW { return DBL_MAX; }
  381. static double _STLP_CALL epsilon() _STLP_NOTHROW { return DBL_EPSILON; }
  382. static double _STLP_CALL round_error() _STLP_NOTHROW { return 0.5; } // Units: ulps.
  383. static double _STLP_CALL infinity() _STLP_NOTHROW { return _STLP_PRIV _LimG<bool>::get_D_inf(); }
  384. static double _STLP_CALL quiet_NaN() _STLP_NOTHROW { return _STLP_PRIV _LimG<bool>::get_D_qNaN(); }
  385. static double _STLP_CALL signaling_NaN() _STLP_NOTHROW { return _STLP_PRIV _LimG<bool>::get_D_sNaN(); }
  386. };
  387. #if !defined (_STLP_NO_LONG_DOUBLE)
  388. _STLP_TEMPLATE_NULL
  389. class numeric_limits<long double>
  390. : public _STLP_PRIV _Floating_limits<long double,
  391. LDBL_MANT_DIG, // Binary digits of precision
  392. LDBL_DIG, // Decimal digits of precision
  393. LDBL_MIN_EXP, // Minimum exponent
  394. LDBL_MAX_EXP, // Maximum exponent
  395. LDBL_MIN_10_EXP,// Minimum base 10 exponent
  396. LDBL_MAX_10_EXP,// Maximum base 10 exponent
  397. false, // do not conform to iec559
  398. _STLP_LDBL_DENORM_STYLE,
  399. round_to_nearest> {
  400. public:
  401. static long double (_STLP_CALL min) () _STLP_NOTHROW { return LDBL_MIN; }
  402. static long double _STLP_CALL denorm_min() _STLP_NOTHROW
  403. #if defined (_STLP_LDBL_DENORM_MIN)
  404. { return _STLP_LDBL_DENORM_MIN; }
  405. #else
  406. { return _STLP_LDBL_DENORM_STYLE ? _STLP_PRIV _LimG<bool>::get_LD_denormMin() : LDBL_MIN; }
  407. #endif
  408. _STLP_STATIC_CONSTANT(bool, is_iec559 = false);
  409. static long double (_STLP_CALL max) () _STLP_NOTHROW { return LDBL_MAX; }
  410. static long double _STLP_CALL epsilon() _STLP_NOTHROW { return LDBL_EPSILON; }
  411. static long double _STLP_CALL round_error() _STLP_NOTHROW { return 0.5l; }
  412. static long double _STLP_CALL infinity() _STLP_NOTHROW
  413. //For MSVC, long double is nothing more than an alias for double.
  414. #if !defined (_STLP_MSVC)
  415. { return _STLP_PRIV _LimG<bool>::get_LD_inf(); }
  416. #else
  417. { return _STLP_PRIV _LimG<bool>::get_D_inf(); }
  418. #endif
  419. static long double _STLP_CALL quiet_NaN() _STLP_NOTHROW
  420. #if !defined (_STLP_MSVC)
  421. { return _STLP_PRIV _LimG<bool>::get_LD_qNaN(); }
  422. #else
  423. { return _STLP_PRIV _LimG<bool>::get_D_qNaN(); }
  424. #endif
  425. static long double _STLP_CALL signaling_NaN() _STLP_NOTHROW
  426. #if !defined (_STLP_MSVC)
  427. { return _STLP_PRIV _LimG<bool>::get_LD_sNaN(); }
  428. #else
  429. { return _STLP_PRIV _LimG<bool>::get_D_sNaN(); }
  430. #endif
  431. };
  432. #endif
  433. // We write special values (Inf and NaN) as bit patterns and
  434. // cast the the appropriate floating-point types.
  435. _STLP_END_NAMESPACE
  436. #if !defined (_STLP_LINK_TIME_INSTANTIATION)
  437. # include <stl/_limits.c>
  438. #endif
  439. #endif
  440. // Local Variables:
  441. // mode:C++
  442. // End: