Source code of Windows XP (NT5)
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.

326 lines
9.1 KiB

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