Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

437 lines
14 KiB

  1. // limits standard header
  2. #ifndef _LIMITS_
  3. #define _LIMITS_
  4. #include <ymath.h>
  5. #include <cfloat>
  6. #include <climits>
  7. #include <cmath>
  8. #include <cwchar>
  9. #include <xstddef>
  10. #ifdef _MSC_VER
  11. #pragma pack(push,8)
  12. #endif /* _MSC_VER */
  13. // ASSUMES:
  14. // wraparound 2's complement integer arithmetic w/o traps
  15. // all CHAR_BITs of each byte used by integers
  16. // IEC559 (IEEE 754) floating-point arithmetic
  17. // floating-point errors can trap
  18. // tinyness detected before floating-point rounding
  19. _STD_BEGIN
  20. // ENUM float_round_style
  21. typedef enum {
  22. round_indeterminate = -1, round_toward_zero = 0,
  23. round_to_nearest = 1, round_toward_infinity = 2,
  24. round_toward_neg_infinity = 3} float_round_style;
  25. // STRUCT _Num_base
  26. struct _CRTIMP2 _Num_base {
  27. _STCONS(bool, has_denorm, false);
  28. _STCONS(bool, has_denorm_loss, false);
  29. _STCONS(bool, has_infinity, false);
  30. _STCONS(bool, has_quiet_NaN, false);
  31. _STCONS(bool, has_signaling_NaN, false);
  32. _STCONS(bool, is_bounded, false);
  33. _STCONS(bool, is_exact, false);
  34. _STCONS(bool, is_iec559, false);
  35. _STCONS(bool, is_integer, false);
  36. _STCONS(bool, is_modulo, false);
  37. _STCONS(bool, is_signed, false);
  38. _STCONS(bool, is_specialized, false);
  39. _STCONS(bool, tinyness_before, false);
  40. _STCONS(bool, traps, false);
  41. _STCONS(float_round_style, round_style, round_toward_zero);
  42. _STCONS(int, digits, 0);
  43. _STCONS(int, digits10, 0);
  44. _STCONS(int, max_exponent, 0);
  45. _STCONS(int, max_exponent10, 0);
  46. _STCONS(int, min_exponent, 0);
  47. _STCONS(int, min_exponent10, 0);
  48. _STCONS(int, radix, 0);
  49. };
  50. // TEMPLATE CLASS numeric_limits
  51. template<class _Ty> class numeric_limits : public _Num_base {
  52. public:
  53. static _Ty (__cdecl min)() _THROW0()
  54. {return (_Ty(0)); }
  55. static _Ty (__cdecl max)() _THROW0()
  56. {return (_Ty(0)); }
  57. static _Ty __cdecl epsilon() _THROW0()
  58. {return (_Ty(0)); }
  59. static _Ty __cdecl round_error() _THROW0()
  60. {return (_Ty(0)); }
  61. static _Ty __cdecl denorm_min() _THROW0()
  62. {return (_Ty(0)); }
  63. static _Ty __cdecl infinity() _THROW0()
  64. {return (_Ty(0)); }
  65. static _Ty __cdecl quiet_NaN() _THROW0()
  66. {return (_Ty(0)); }
  67. static _Ty __cdecl signaling_NaN() _THROW0()
  68. {return (_Ty(0)); }
  69. };
  70. // STRUCT _Num_int_base
  71. struct _CRTIMP2 _Num_int_base : public _Num_base {
  72. _STCONS(bool, is_bounded, true);
  73. _STCONS(bool, is_exact, true);
  74. _STCONS(bool, is_integer, true);
  75. _STCONS(bool, is_modulo, true);
  76. _STCONS(bool, is_specialized, true);
  77. _STCONS(int, radix, 2);
  78. };
  79. // STRUCT _Num_float_base
  80. struct _CRTIMP2 _Num_float_base : public _Num_base {
  81. _STCONS(bool, has_denorm, true);
  82. _STCONS(bool, has_denorm_loss, true);
  83. _STCONS(bool, has_infinity, true);
  84. _STCONS(bool, has_quiet_NaN, true);
  85. _STCONS(bool, has_signaling_NaN, true);
  86. _STCONS(bool, is_bounded, true);
  87. _STCONS(bool, is_exact, false);
  88. _STCONS(bool, is_iec559, true);
  89. _STCONS(bool, is_integer, false);
  90. _STCONS(bool, is_modulo, false);
  91. _STCONS(bool, is_signed, true);
  92. _STCONS(bool, is_specialized, true);
  93. _STCONS(bool, tinyness_before, true);
  94. _STCONS(bool, traps, true);
  95. _STCONS(float_round_style, round_style, round_to_nearest);
  96. _STCONS(int, radix, FLT_RADIX);
  97. };
  98. // CLASS numeric_limits<char>
  99. class _CRTIMP2 numeric_limits<char> : public _Num_int_base {
  100. public:
  101. typedef char _Ty;
  102. static _Ty (__cdecl min)() _THROW0()
  103. {return (CHAR_MIN); }
  104. static _Ty (__cdecl max)() _THROW0()
  105. {return (CHAR_MAX); }
  106. static _Ty __cdecl epsilon() _THROW0()
  107. {return (0); }
  108. static _Ty __cdecl round_error() _THROW0()
  109. {return (0); }
  110. static _Ty __cdecl denorm_min() _THROW0()
  111. {return (0); }
  112. static _Ty __cdecl infinity() _THROW0()
  113. {return (0); }
  114. static _Ty __cdecl quiet_NaN() _THROW0()
  115. {return (0); }
  116. static _Ty __cdecl signaling_NaN() _THROW0()
  117. {return (0); }
  118. _STCONS(bool, is_signed, CHAR_MIN < 0);
  119. _STCONS(int, digits, CHAR_BIT - (CHAR_MIN < 0 ? 1 : 0));
  120. _STCONS(int, digits10, (CHAR_BIT - (CHAR_MIN < 0 ? 1 : 0))
  121. * 301L / 1000);
  122. };
  123. // CLASS numeric_limits<_Bool>
  124. class _CRTIMP2 numeric_limits<_Bool> : public _Num_int_base {
  125. public:
  126. typedef bool _Ty;
  127. static _Ty (__cdecl min)() _THROW0()
  128. {return (false); }
  129. static _Ty (__cdecl max)() _THROW0()
  130. {return (true); }
  131. static _Ty __cdecl epsilon() _THROW0()
  132. {return (0); }
  133. static _Ty __cdecl round_error() _THROW0()
  134. {return (0); }
  135. static _Ty __cdecl denorm_min() _THROW0()
  136. {return (0); }
  137. static _Ty __cdecl infinity() _THROW0()
  138. {return (0); }
  139. static _Ty __cdecl quiet_NaN() _THROW0()
  140. {return (0); }
  141. static _Ty __cdecl signaling_NaN() _THROW0()
  142. {return (0); }
  143. _STCONS(bool, is_signed, false);
  144. _STCONS(int, digits, 1);
  145. _STCONS(int, digits10, 0);
  146. };
  147. // CLASS numeric_limits<signed char>
  148. class _CRTIMP2 numeric_limits<signed char> : public _Num_int_base {
  149. public:
  150. typedef signed char _Ty;
  151. static _Ty (__cdecl min)() _THROW0()
  152. {return (SCHAR_MIN); }
  153. static _Ty (__cdecl max)() _THROW0()
  154. {return (SCHAR_MAX); }
  155. static _Ty __cdecl epsilon() _THROW0()
  156. {return (0); }
  157. static _Ty __cdecl round_error() _THROW0()
  158. {return (0); }
  159. static _Ty __cdecl denorm_min() _THROW0()
  160. {return (0); }
  161. static _Ty __cdecl infinity() _THROW0()
  162. {return (0); }
  163. static _Ty __cdecl quiet_NaN() _THROW0()
  164. {return (0); }
  165. static _Ty __cdecl signaling_NaN() _THROW0()
  166. {return (0); }
  167. _STCONS(bool, is_signed, true);
  168. _STCONS(int, digits, CHAR_BIT - 1);
  169. _STCONS(int, digits10, (CHAR_BIT - 1) * 301L / 1000);
  170. };
  171. // CLASS numeric_limits<unsigned char>
  172. class _CRTIMP2 numeric_limits<unsigned char> : public _Num_int_base {
  173. public:
  174. typedef unsigned char _Ty;
  175. static _Ty (__cdecl min)() _THROW0()
  176. {return (0); }
  177. static _Ty (__cdecl max)() _THROW0()
  178. {return (UCHAR_MAX); }
  179. static _Ty __cdecl epsilon() _THROW0()
  180. {return (0); }
  181. static _Ty __cdecl round_error() _THROW0()
  182. {return (0); }
  183. static _Ty __cdecl denorm_min() _THROW0()
  184. {return (0); }
  185. static _Ty __cdecl infinity() _THROW0()
  186. {return (0); }
  187. static _Ty __cdecl quiet_NaN() _THROW0()
  188. {return (0); }
  189. static _Ty __cdecl signaling_NaN() _THROW0()
  190. {return (0); }
  191. _STCONS(bool, is_signed, false);
  192. _STCONS(int, digits, CHAR_BIT);
  193. _STCONS(int, digits10, (CHAR_BIT) * 301L / 1000);
  194. };
  195. // CLASS numeric_limits<short>
  196. class _CRTIMP2 numeric_limits<short> : public _Num_int_base {
  197. public:
  198. typedef short _Ty;
  199. static _Ty (__cdecl min)() _THROW0()
  200. {return (SHRT_MIN); }
  201. static _Ty (__cdecl max)() _THROW0()
  202. {return (SHRT_MAX); }
  203. static _Ty __cdecl epsilon() _THROW0()
  204. {return (0); }
  205. static _Ty __cdecl round_error() _THROW0()
  206. {return (0); }
  207. static _Ty __cdecl denorm_min() _THROW0()
  208. {return (0); }
  209. static _Ty __cdecl infinity() _THROW0()
  210. {return (0); }
  211. static _Ty __cdecl quiet_NaN() _THROW0()
  212. {return (0); }
  213. static _Ty __cdecl signaling_NaN() _THROW0()
  214. {return (0); }
  215. _STCONS(bool, is_signed, true);
  216. _STCONS(int, digits, CHAR_BIT * sizeof (short) - 1);
  217. _STCONS(int, digits10, (CHAR_BIT * sizeof (short) - 1)
  218. * 301L / 1000);
  219. };
  220. // CLASS numeric_limits<unsigned short>
  221. class _CRTIMP2 numeric_limits<unsigned short> : public _Num_int_base {
  222. public:
  223. typedef unsigned short _Ty;
  224. static _Ty (__cdecl min)() _THROW0()
  225. {return (0); }
  226. static _Ty (__cdecl max)() _THROW0()
  227. {return (USHRT_MAX); }
  228. static _Ty __cdecl epsilon() _THROW0()
  229. {return (0); }
  230. static _Ty __cdecl round_error() _THROW0()
  231. {return (0); }
  232. static _Ty __cdecl denorm_min() _THROW0()
  233. {return (0); }
  234. static _Ty __cdecl infinity() _THROW0()
  235. {return (0); }
  236. static _Ty __cdecl quiet_NaN() _THROW0()
  237. {return (0); }
  238. static _Ty __cdecl signaling_NaN() _THROW0()
  239. {return (0); }
  240. _STCONS(bool, is_signed, false);
  241. _STCONS(int, digits, CHAR_BIT * sizeof (unsigned short));
  242. _STCONS(int, digits10, (CHAR_BIT * sizeof (unsigned short))
  243. * 301L / 1000);
  244. };
  245. // CLASS numeric_limits<int>
  246. class _CRTIMP2 numeric_limits<int> : public _Num_int_base {
  247. public:
  248. typedef int _Ty;
  249. static _Ty (__cdecl min)() _THROW0()
  250. {return (INT_MIN); }
  251. static _Ty (__cdecl max)() _THROW0()
  252. {return (INT_MAX); }
  253. static _Ty __cdecl epsilon() _THROW0()
  254. {return (0); }
  255. static _Ty __cdecl round_error() _THROW0()
  256. {return (0); }
  257. static _Ty __cdecl denorm_min() _THROW0()
  258. {return (0); }
  259. static _Ty __cdecl infinity() _THROW0()
  260. {return (0); }
  261. static _Ty __cdecl quiet_NaN() _THROW0()
  262. {return (0); }
  263. static _Ty __cdecl signaling_NaN() _THROW0()
  264. {return (0); }
  265. _STCONS(bool, is_signed, true);
  266. _STCONS(int, digits, CHAR_BIT * sizeof (int) - 1);
  267. _STCONS(int, digits10, (CHAR_BIT * sizeof (int) - 1)
  268. * 301L / 1000);
  269. };
  270. // CLASS numeric_limits<unsigned int>
  271. class _CRTIMP2 numeric_limits<unsigned int> : public _Num_int_base {
  272. public:
  273. typedef unsigned int _Ty;
  274. static _Ty (__cdecl min)() _THROW0()
  275. {return (0); }
  276. static _Ty (__cdecl max)() _THROW0()
  277. {return (UINT_MAX); }
  278. static _Ty __cdecl epsilon() _THROW0()
  279. {return (0); }
  280. static _Ty __cdecl round_error() _THROW0()
  281. {return (0); }
  282. static _Ty __cdecl denorm_min() _THROW0()
  283. {return (0); }
  284. static _Ty __cdecl infinity() _THROW0()
  285. {return (0); }
  286. static _Ty __cdecl quiet_NaN() _THROW0()
  287. {return (0); }
  288. static _Ty __cdecl signaling_NaN() _THROW0()
  289. {return (0); }
  290. _STCONS(bool, is_signed, false);
  291. _STCONS(int, digits, CHAR_BIT * sizeof (unsigned int));
  292. _STCONS(int, digits10, (CHAR_BIT * sizeof (unsigned int))
  293. * 301L / 1000);
  294. };
  295. // CLASS numeric_limits<long>
  296. class _CRTIMP2 numeric_limits<long> : public _Num_int_base {
  297. public:
  298. typedef long _Ty;
  299. static _Ty (__cdecl min)() _THROW0()
  300. {return (LONG_MIN); }
  301. static _Ty (__cdecl max)() _THROW0()
  302. {return (LONG_MAX); }
  303. static _Ty __cdecl epsilon() _THROW0()
  304. {return (0); }
  305. static _Ty __cdecl round_error() _THROW0()
  306. {return (0); }
  307. static _Ty __cdecl denorm_min() _THROW0()
  308. {return (0); }
  309. static _Ty __cdecl infinity() _THROW0()
  310. {return (0); }
  311. static _Ty __cdecl quiet_NaN() _THROW0()
  312. {return (0); }
  313. static _Ty __cdecl signaling_NaN() _THROW0()
  314. {return (0); }
  315. _STCONS(bool, is_signed, true);
  316. _STCONS(int, digits, CHAR_BIT * sizeof (long) - 1);
  317. _STCONS(int, digits10, (CHAR_BIT * sizeof (long) - 1)
  318. * 301L / 1000);
  319. };
  320. // CLASS numeric_limits<unsigned long>
  321. class _CRTIMP2 numeric_limits<unsigned long> : public _Num_int_base {
  322. public:
  323. typedef unsigned long _Ty;
  324. static _Ty (__cdecl min)() _THROW0()
  325. {return (0); }
  326. static _Ty (__cdecl max)() _THROW0()
  327. {return (ULONG_MAX); }
  328. static _Ty __cdecl epsilon() _THROW0()
  329. {return (0); }
  330. static _Ty __cdecl round_error() _THROW0()
  331. {return (0); }
  332. static _Ty __cdecl denorm_min() _THROW0()
  333. {return (0); }
  334. static _Ty __cdecl infinity() _THROW0()
  335. {return (0); }
  336. static _Ty __cdecl quiet_NaN() _THROW0()
  337. {return (0); }
  338. static _Ty __cdecl signaling_NaN() _THROW0()
  339. {return (0); }
  340. _STCONS(bool, is_signed, false);
  341. _STCONS(int, digits, CHAR_BIT * sizeof (unsigned long));
  342. _STCONS(int, digits10, (CHAR_BIT * sizeof (unsigned long))
  343. * 301L / 1000);
  344. };
  345. // CLASS numeric_limits<float>
  346. class _CRTIMP2 numeric_limits<float> : public _Num_float_base {
  347. public:
  348. typedef float _Ty;
  349. static _Ty (__cdecl min)() _THROW0()
  350. {return (FLT_MIN); }
  351. static _Ty (__cdecl max)() _THROW0()
  352. {return (FLT_MAX); }
  353. static _Ty __cdecl epsilon() _THROW0()
  354. {return (FLT_EPSILON); }
  355. static _Ty __cdecl round_error() _THROW0()
  356. {return (0.5); }
  357. static _Ty __cdecl denorm_min() _THROW0()
  358. {return (_FDenorm._F); }
  359. static _Ty __cdecl infinity() _THROW0()
  360. {return (_FInf._F); }
  361. static _Ty __cdecl quiet_NaN() _THROW0()
  362. {return (_FNan._F); }
  363. static _Ty __cdecl signaling_NaN() _THROW0()
  364. {return (_FSnan._F); }
  365. _STCONS(int, digits, FLT_MANT_DIG);
  366. _STCONS(int, digits10, FLT_DIG);
  367. _STCONS(int, max_exponent, FLT_MAX_EXP);
  368. _STCONS(int, max_exponent10, FLT_MAX_10_EXP);
  369. _STCONS(int, min_exponent, FLT_MIN_EXP);
  370. _STCONS(int, min_exponent10, FLT_MIN_10_EXP);
  371. };
  372. // CLASS numeric_limits<double>
  373. class _CRTIMP2 numeric_limits<double> : public _Num_float_base {
  374. public:
  375. typedef double _Ty;
  376. static _Ty (__cdecl min)() _THROW0()
  377. {return (DBL_MIN); }
  378. static _Ty (__cdecl max)() _THROW0()
  379. {return (DBL_MAX); }
  380. static _Ty __cdecl epsilon() _THROW0()
  381. {return (DBL_EPSILON); }
  382. static _Ty __cdecl round_error() _THROW0()
  383. {return (0.5); }
  384. static _Ty __cdecl denorm_min() _THROW0()
  385. {return (_Denorm._D); }
  386. static _Ty __cdecl infinity() _THROW0()
  387. {return (_Inf._D); }
  388. static _Ty __cdecl quiet_NaN() _THROW0()
  389. {return (_Nan._D); }
  390. static _Ty __cdecl signaling_NaN() _THROW0()
  391. {return (_Snan._D); }
  392. _STCONS(int, digits, DBL_MANT_DIG);
  393. _STCONS(int, digits10, DBL_DIG);
  394. _STCONS(int, max_exponent, DBL_MAX_EXP);
  395. _STCONS(int, max_exponent10, DBL_MAX_10_EXP);
  396. _STCONS(int, min_exponent, DBL_MIN_EXP);
  397. _STCONS(int, min_exponent10, DBL_MIN_10_EXP);
  398. };
  399. // CLASS numeric_limits<long double>
  400. class _CRTIMP2 numeric_limits<long double> : public _Num_float_base {
  401. public:
  402. typedef long double _Ty;
  403. static _Ty (__cdecl min)() _THROW0()
  404. {return (LDBL_MIN); }
  405. static _Ty (__cdecl max)() _THROW0()
  406. {return (LDBL_MAX); }
  407. static _Ty __cdecl epsilon() _THROW0()
  408. {return (LDBL_EPSILON); }
  409. static _Ty __cdecl round_error() _THROW0()
  410. {return (0.5); }
  411. static _Ty __cdecl denorm_min() _THROW0()
  412. {return (_LDenorm._L); }
  413. static _Ty __cdecl infinity() _THROW0()
  414. {return (_LInf._L); }
  415. static _Ty __cdecl quiet_NaN() _THROW0()
  416. {return (_LNan._L); }
  417. static _Ty __cdecl signaling_NaN() _THROW0()
  418. {return (_LSnan._L); }
  419. _STCONS(int, digits, LDBL_MANT_DIG);
  420. _STCONS(int, digits10, LDBL_DIG);
  421. _STCONS(int, max_exponent, LDBL_MAX_EXP);
  422. _STCONS(int, max_exponent10, LDBL_MAX_10_EXP);
  423. _STCONS(int, min_exponent, LDBL_MIN_EXP);
  424. _STCONS(int, min_exponent10, LDBL_MIN_10_EXP);
  425. };
  426. _STD_END
  427. #ifdef _MSC_VER
  428. #pragma pack(pop)
  429. #endif /* _MSC_VER */
  430. #endif /* _LIMITS_ */
  431. /*
  432. * Copyright (c) 1995 by P.J. Plauger. ALL RIGHTS RESERVED.
  433. * Consult your license regarding permissions and restrictions.
  434. */