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.

298 lines
11 KiB

  1. /***
  2. *float.h - constants for floating point values
  3. *
  4. * Copyright (c) 1985-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * This file contains defines for a number of implementation dependent
  8. * values which are commonly used by sophisticated numerical (floating
  9. * point) programs.
  10. * [ANSI]
  11. *
  12. * [Public]
  13. *
  14. ****/
  15. #if _MSC_VER > 1000
  16. #pragma once
  17. #endif
  18. #ifndef _INC_FLOAT
  19. #define _INC_FLOAT
  20. #if !defined(_WIN32)
  21. #error ERROR: Only Win32 target supported!
  22. #endif
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. /* Define _CRTIMP */
  27. #ifndef _CRTIMP
  28. #ifdef _DLL
  29. #define _CRTIMP __declspec(dllimport)
  30. #else /* ndef _DLL */
  31. #define _CRTIMP
  32. #endif /* _DLL */
  33. #endif /* _CRTIMP */
  34. /* Define __cdecl for non-Microsoft compilers */
  35. #if ( !defined(_MSC_VER) && !defined(__cdecl) )
  36. #define __cdecl
  37. #endif
  38. #define DBL_DIG 15 /* # of decimal digits of precision */
  39. #define DBL_EPSILON 2.2204460492503131e-016 /* smallest such that 1.0+DBL_EPSILON != 1.0 */
  40. #define DBL_MANT_DIG 53 /* # of bits in mantissa */
  41. #define DBL_MAX 1.7976931348623158e+308 /* max value */
  42. #define DBL_MAX_10_EXP 308 /* max decimal exponent */
  43. #define DBL_MAX_EXP 1024 /* max binary exponent */
  44. #define DBL_MIN 2.2250738585072014e-308 /* min positive value */
  45. #define DBL_MIN_10_EXP (-307) /* min decimal exponent */
  46. #define DBL_MIN_EXP (-1021) /* min binary exponent */
  47. #define _DBL_RADIX 2 /* exponent radix */
  48. #define _DBL_ROUNDS 1 /* addition rounding: near */
  49. #define FLT_DIG 6 /* # of decimal digits of precision */
  50. #define FLT_EPSILON 1.192092896e-07F /* smallest such that 1.0+FLT_EPSILON != 1.0 */
  51. #define FLT_GUARD 0
  52. #define FLT_MANT_DIG 24 /* # of bits in mantissa */
  53. #define FLT_MAX 3.402823466e+38F /* max value */
  54. #define FLT_MAX_10_EXP 38 /* max decimal exponent */
  55. #define FLT_MAX_EXP 128 /* max binary exponent */
  56. #define FLT_MIN 1.175494351e-38F /* min positive value */
  57. #define FLT_MIN_10_EXP (-37) /* min decimal exponent */
  58. #define FLT_MIN_EXP (-125) /* min binary exponent */
  59. #define FLT_NORMALIZE 0
  60. #define FLT_RADIX 2 /* exponent radix */
  61. #define FLT_ROUNDS 1 /* addition rounding: near */
  62. #define LDBL_DIG DBL_DIG /* # of decimal digits of precision */
  63. #define LDBL_EPSILON DBL_EPSILON /* smallest such that 1.0+LDBL_EPSILON != 1.0 */
  64. #define LDBL_MANT_DIG DBL_MANT_DIG /* # of bits in mantissa */
  65. #define LDBL_MAX DBL_MAX /* max value */
  66. #define LDBL_MAX_10_EXP DBL_MAX_10_EXP /* max decimal exponent */
  67. #define LDBL_MAX_EXP DBL_MAX_EXP /* max binary exponent */
  68. #define LDBL_MIN DBL_MIN /* min positive value */
  69. #define LDBL_MIN_10_EXP DBL_MIN_10_EXP /* min decimal exponent */
  70. #define LDBL_MIN_EXP DBL_MIN_EXP /* min binary exponent */
  71. #define _LDBL_RADIX DBL_RADIX /* exponent radix */
  72. #define _LDBL_ROUNDS DBL_ROUNDS /* addition rounding: near */
  73. /* Function prototypes */
  74. _CRTIMP unsigned int __cdecl _clearfp(void);
  75. _CRTIMP unsigned int __cdecl _controlfp(unsigned int,unsigned int);
  76. _CRTIMP unsigned int __cdecl _statusfp(void);
  77. _CRTIMP void __cdecl _fpreset(void);
  78. #define _clear87 _clearfp
  79. #define _status87 _statusfp
  80. /*
  81. * Abstract User Control Word Mask and bit definitions
  82. */
  83. #define _MCW_EM 0x0008001f /* interrupt Exception Masks */
  84. #define _EM_INEXACT 0x00000001 /* inexact (precision) */
  85. #define _EM_UNDERFLOW 0x00000002 /* underflow */
  86. #define _EM_OVERFLOW 0x00000004 /* overflow */
  87. #define _EM_ZERODIVIDE 0x00000008 /* zero divide */
  88. #define _EM_INVALID 0x00000010 /* invalid */
  89. #define _MCW_RC 0x00000300 /* Rounding Control */
  90. #define _RC_NEAR 0x00000000 /* near */
  91. #define _RC_DOWN 0x00000100 /* down */
  92. #define _RC_UP 0x00000200 /* up */
  93. #define _RC_CHOP 0x00000300 /* chop */
  94. /*
  95. * Abstract User Status Word bit definitions
  96. */
  97. #define _SW_INEXACT 0x00000001 /* inexact (precision) */
  98. #define _SW_UNDERFLOW 0x00000002 /* underflow */
  99. #define _SW_OVERFLOW 0x00000004 /* overflow */
  100. #define _SW_ZERODIVIDE 0x00000008 /* zero divide */
  101. #define _SW_INVALID 0x00000010 /* invalid */
  102. /*
  103. * i386 specific definitions
  104. */
  105. #define _MCW_PC 0x00030000 /* Precision Control */
  106. #define _PC_64 0x00000000 /* 64 bits */
  107. #define _PC_53 0x00010000 /* 53 bits */
  108. #define _PC_24 0x00020000 /* 24 bits */
  109. #define _MCW_IC 0x00040000 /* Infinity Control */
  110. #define _IC_AFFINE 0x00040000 /* affine */
  111. #define _IC_PROJECTIVE 0x00000000 /* projective */
  112. #define _EM_DENORMAL 0x00080000 /* denormal exception mask (_control87 only) */
  113. #define _SW_DENORMAL 0x00080000 /* denormal status bit */
  114. _CRTIMP unsigned int __cdecl _control87(unsigned int,unsigned int);
  115. /*
  116. * RISC specific definitions
  117. */
  118. #define _MCW_DN 0x03000000 /* Denormal Control */
  119. #define _DN_SAVE 0x00000000 /* save denormal results and operands */
  120. #define _DN_FLUSH 0x01000000 /* flush denormal results and operands to zero */
  121. #define _DN_FLUSH_OPERANDS_SAVE_RESULTS 0x02000000 /* flush operands to zero and save results */
  122. #define _DN_SAVE_OPERANDS_FLUSH_RESULTS 0x03000000 /* save operands and flush results to zero */
  123. /* initial Control Word value */
  124. #if defined(_M_IX86)
  125. #define _CW_DEFAULT ( _RC_NEAR + _PC_53 + _EM_INVALID + _EM_ZERODIVIDE + _EM_OVERFLOW + _EM_UNDERFLOW + _EM_INEXACT + _EM_DENORMAL)
  126. #elif defined(_M_IA64) || defined(_M_AMD64)
  127. #define _CW_DEFAULT ( _RC_NEAR + _PC_64 + _EM_INVALID + _EM_ZERODIVIDE + _EM_OVERFLOW + _EM_UNDERFLOW + _EM_INEXACT + _EM_DENORMAL)
  128. #endif
  129. /* Global variable holding floating point error code */
  130. #if defined(_MT) || defined(_DLL)
  131. _CRTIMP extern int * __cdecl __fpecode(void);
  132. #define _fpecode (*__fpecode())
  133. #else /* ndef _MT && ndef _DLL */
  134. extern int _fpecode;
  135. #endif /* _MT || _DLL */
  136. /* invalid subconditions (_SW_INVALID also set) */
  137. #define _SW_UNEMULATED 0x0040 /* unemulated instruction */
  138. #define _SW_SQRTNEG 0x0080 /* square root of a neg number */
  139. #define _SW_STACKOVERFLOW 0x0200 /* FP stack overflow */
  140. #define _SW_STACKUNDERFLOW 0x0400 /* FP stack underflow */
  141. /* Floating point error signals and return codes */
  142. #define _FPE_INVALID 0x81
  143. #define _FPE_DENORMAL 0x82
  144. #define _FPE_ZERODIVIDE 0x83
  145. #define _FPE_OVERFLOW 0x84
  146. #define _FPE_UNDERFLOW 0x85
  147. #define _FPE_INEXACT 0x86
  148. #define _FPE_UNEMULATED 0x87
  149. #define _FPE_SQRTNEG 0x88
  150. #define _FPE_STACKOVERFLOW 0x8a
  151. #define _FPE_STACKUNDERFLOW 0x8b
  152. #define _FPE_EXPLICITGEN 0x8c /* raise( SIGFPE ); */
  153. /* IEEE recommended functions */
  154. _CRTIMP double __cdecl _copysign (double, double);
  155. _CRTIMP double __cdecl _chgsign (double);
  156. _CRTIMP double __cdecl _scalb(double, long);
  157. _CRTIMP double __cdecl _logb(double);
  158. _CRTIMP double __cdecl _nextafter(double, double);
  159. _CRTIMP int __cdecl _finite(double);
  160. _CRTIMP int __cdecl _isnan(double);
  161. _CRTIMP int __cdecl _fpclass(double);
  162. #define _FPCLASS_SNAN 0x0001 /* signaling NaN */
  163. #define _FPCLASS_QNAN 0x0002 /* quiet NaN */
  164. #define _FPCLASS_NINF 0x0004 /* negative infinity */
  165. #define _FPCLASS_NN 0x0008 /* negative normal */
  166. #define _FPCLASS_ND 0x0010 /* negative denormal */
  167. #define _FPCLASS_NZ 0x0020 /* -0 */
  168. #define _FPCLASS_PZ 0x0040 /* +0 */
  169. #define _FPCLASS_PD 0x0080 /* positive denormal */
  170. #define _FPCLASS_PN 0x0100 /* positive normal */
  171. #define _FPCLASS_PINF 0x0200 /* positive infinity */
  172. #if !__STDC__
  173. /* Non-ANSI names for compatibility */
  174. #define clear87 _clear87
  175. #define status87 _status87
  176. #define control87 _control87
  177. _CRTIMP void __cdecl fpreset(void);
  178. #define DBL_RADIX _DBL_RADIX
  179. #define DBL_ROUNDS _DBL_ROUNDS
  180. #define LDBL_RADIX _LDBL_RADIX
  181. #define LDBL_ROUNDS _LDBL_ROUNDS
  182. #define MCW_EM _MCW_EM
  183. #define EM_INVALID _EM_INVALID
  184. #define EM_DENORMAL _EM_DENORMAL
  185. #define EM_ZERODIVIDE _EM_ZERODIVIDE
  186. #define EM_OVERFLOW _EM_OVERFLOW
  187. #define EM_UNDERFLOW _EM_UNDERFLOW
  188. #define EM_INEXACT _EM_INEXACT
  189. #define MCW_IC _MCW_IC
  190. #define IC_AFFINE _IC_AFFINE
  191. #define IC_PROJECTIVE _IC_PROJECTIVE
  192. #define MCW_RC _MCW_RC
  193. #define RC_CHOP _RC_CHOP
  194. #define RC_UP _RC_UP
  195. #define RC_DOWN _RC_DOWN
  196. #define RC_NEAR _RC_NEAR
  197. #define MCW_PC _MCW_PC
  198. #define PC_24 _PC_24
  199. #define PC_53 _PC_53
  200. #define PC_64 _PC_64
  201. #define CW_DEFAULT _CW_DEFAULT
  202. #define SW_INVALID _SW_INVALID
  203. #define SW_DENORMAL _SW_DENORMAL
  204. #define SW_ZERODIVIDE _SW_ZERODIVIDE
  205. #define SW_OVERFLOW _SW_OVERFLOW
  206. #define SW_UNDERFLOW _SW_UNDERFLOW
  207. #define SW_INEXACT _SW_INEXACT
  208. #define SW_UNEMULATED _SW_UNEMULATED
  209. #define SW_SQRTNEG _SW_SQRTNEG
  210. #define SW_STACKOVERFLOW _SW_STACKOVERFLOW
  211. #define SW_STACKUNDERFLOW _SW_STACKUNDERFLOW
  212. #define FPE_INVALID _FPE_INVALID
  213. #define FPE_DENORMAL _FPE_DENORMAL
  214. #define FPE_ZERODIVIDE _FPE_ZERODIVIDE
  215. #define FPE_OVERFLOW _FPE_OVERFLOW
  216. #define FPE_UNDERFLOW _FPE_UNDERFLOW
  217. #define FPE_INEXACT _FPE_INEXACT
  218. #define FPE_UNEMULATED _FPE_UNEMULATED
  219. #define FPE_SQRTNEG _FPE_SQRTNEG
  220. #define FPE_STACKOVERFLOW _FPE_STACKOVERFLOW
  221. #define FPE_STACKUNDERFLOW _FPE_STACKUNDERFLOW
  222. #define FPE_EXPLICITGEN _FPE_EXPLICITGEN
  223. #endif /* __STDC__ */
  224. #ifdef __cplusplus
  225. }
  226. #endif
  227. #endif /* _INC_FLOAT */