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.

376 lines
15 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. *Revision History:
  15. * 08-05-87 PHG added comments
  16. * 12-11-87 JCR Added "_loadds" functionality
  17. * 12-18-87 JCR Added _FAR_ to declarations
  18. * 02-10-88 JCR Cleaned up white space
  19. * 07-12-88 JCR Added some close comment delimeters (bug fix)
  20. * 08-22-88 GJF Modified to also work with the 386 (small model only)
  21. * 12-16-88 GJF Changed [FLT|DBL|LDBL]_ROUNDS to 1
  22. * 04-28-89 SKS Put parentheses around negative constants
  23. * 05-03-89 JCR Added _INTERNAL_IFSTRIP for relinc usage
  24. * 08-03-89 GJF Cleanup, now specific to OS/2 2.0 (i.e., 386 flat model)
  25. * 10-20-89 KRS Add 'F' to FLT_MAX/MIN/EPSILON consts like in ANSI spec.
  26. * 10-30-89 GJF Fixed copyright
  27. * 11-02-89 JCR Changed "DLL" to "_DLL"
  28. * 02-28-90 GJF Added #ifndef _INC_FLOAT and #include <cruntime.h>
  29. * stuff. Also, removed some (now) useless preprocessor
  30. * directives.
  31. * 03-22-90 GJF Replaced _cdecl with _CALLTYPE2 (for now).
  32. * 08-17-90 WAJ Floating point routines now use _stdcall.
  33. * 09-25-90 GJF Added _fpecode stuff.
  34. * 08-20-91 JCR C++ and ANSI naming
  35. * 02-03-91 GDP Added definitions for MIPS
  36. * 04-03-92 GDP Use abstract control word definitions for all platforms
  37. * Removed Infinity Control, [EM|SW]_DENORMAL, SW_SQRTNEG
  38. * 04-14-92 GDP Added Inf. control, [EM|SW]_DENORMAL, SW_SQRTNEG again
  39. * 05-07-92 GDP Added IEEE recommended functions
  40. * 08-06-92 GJF Function calling type and variable type macros. Also
  41. * revised compiler/target processor macro usage.
  42. * 09-16-92 GJF Added _CRTAPI1 to _copysign - _fpclass prototypes.
  43. * 11-09-92 GJF Fixed preprocessing conditionals for MIPS.
  44. * 01-03-93 SRW Fold in ALPHA changes
  45. * 01-09-93 SRW Remove usage of MIPS and ALPHA to conform to ANSI
  46. * Use _MIPS_ and _ALPHA_ instead.
  47. * 01-21-93 GJF Removed support for C6-386's _cdecl.
  48. * 04-06-93 SKS Replace _CRTAPI1/2 with __cdecl, _CRTVAR1 with nothing
  49. * 04-07-93 SKS Add _CRTIMP keyword for CRT DLL model
  50. * Use link-time aliases for old names, not #define's
  51. * Remove support for DOSX32, non-X86 CPUs, etc.
  52. * 09-01-93 GJF Merged Cuda and NT SDK versions.
  53. * 10-12-93 GJF Re-merged. Dropped use of _MIPS_ and _ALPHA_.
  54. * 06-06-94 SKS Change if def(_MT) to if def(_MT) || def(_DLL)
  55. * This will support single-thread apps using MSVCRT*.DLL
  56. * 10-02-94 BWT Add PPC support.
  57. * 12-15-94 XY merged with mac header
  58. * 02-11-95 CFW Add _CRTBLD to avoid users getting wrong headers.
  59. * 02-14-95 CFW Clean up Mac merge.
  60. * 04-11-95 JWM Redefined CW_DEFAULT for x86.
  61. * 05-24-95 CFW xxx87() nor for mac use.
  62. * 05-24-95 CFW oldnames xxx87() uses macros.
  63. * 12-14-95 JWM Add "#pragma once".
  64. * 02-05-97 GJF Deleted obsolete support for _CRTAPI* and _NTSDK.
  65. * Replaced (defined(_M_MPPC) || defined(_M_M68K)) with
  66. * defined(_MAC) where appropriate. Also, detab-ed.
  67. * 05-21-97 RKP Added new denormal options for ALPHA.
  68. * 09-30-97 JWM Restored not-so-obsolete _CRTAPI1 support.
  69. * 10-07-97 RDL Added IA64.
  70. * 05-13-99 PML Remove _CRTAPI1
  71. * 05-17-99 PML Remove all Macintosh support.
  72. * 06-04-99 PML Define _CW_DEFAULT for IA64.
  73. *
  74. ****/
  75. #if _MSC_VER > 1000 /*IFSTRIP=IGN*/
  76. #pragma once
  77. #endif
  78. #ifndef _INC_FLOAT
  79. #define _INC_FLOAT
  80. #if !defined(_WIN32)
  81. #error ERROR: Only Win32 target supported!
  82. #endif
  83. #ifndef _CRTBLD
  84. /* This version of the header files is NOT for user programs.
  85. * It is intended for use when building the C runtimes ONLY.
  86. * The version intended for public use will not have this message.
  87. */
  88. #error ERROR: Use of C runtime library internal header file.
  89. #endif /* _CRTBLD */
  90. #ifdef __cplusplus
  91. extern "C" {
  92. #endif
  93. #ifndef _INTERNAL_IFSTRIP_
  94. #include <cruntime.h>
  95. #endif /* _INTERNAL_IFSTRIP_ */
  96. /* Define _CRTIMP */
  97. #ifndef _CRTIMP
  98. #ifdef CRTDLL
  99. #define _CRTIMP __declspec(dllexport)
  100. #else /* ndef CRTDLL */
  101. #ifdef _DLL
  102. #define _CRTIMP __declspec(dllimport)
  103. #else /* ndef _DLL */
  104. #define _CRTIMP
  105. #endif /* _DLL */
  106. #endif /* CRTDLL */
  107. #endif /* _CRTIMP */
  108. /* Define __cdecl for non-Microsoft compilers */
  109. #if ( !defined(_MSC_VER) && !defined(__cdecl) )
  110. #define __cdecl
  111. #endif
  112. #define DBL_DIG 15 /* # of decimal digits of precision */
  113. #define DBL_EPSILON 2.2204460492503131e-016 /* smallest such that 1.0+DBL_EPSILON != 1.0 */
  114. #define DBL_MANT_DIG 53 /* # of bits in mantissa */
  115. #define DBL_MAX 1.7976931348623158e+308 /* max value */
  116. #define DBL_MAX_10_EXP 308 /* max decimal exponent */
  117. #define DBL_MAX_EXP 1024 /* max binary exponent */
  118. #define DBL_MIN 2.2250738585072014e-308 /* min positive value */
  119. #define DBL_MIN_10_EXP (-307) /* min decimal exponent */
  120. #define DBL_MIN_EXP (-1021) /* min binary exponent */
  121. #define _DBL_RADIX 2 /* exponent radix */
  122. #define _DBL_ROUNDS 1 /* addition rounding: near */
  123. #define FLT_DIG 6 /* # of decimal digits of precision */
  124. #define FLT_EPSILON 1.192092896e-07F /* smallest such that 1.0+FLT_EPSILON != 1.0 */
  125. #define FLT_GUARD 0
  126. #define FLT_MANT_DIG 24 /* # of bits in mantissa */
  127. #define FLT_MAX 3.402823466e+38F /* max value */
  128. #define FLT_MAX_10_EXP 38 /* max decimal exponent */
  129. #define FLT_MAX_EXP 128 /* max binary exponent */
  130. #define FLT_MIN 1.175494351e-38F /* min positive value */
  131. #define FLT_MIN_10_EXP (-37) /* min decimal exponent */
  132. #define FLT_MIN_EXP (-125) /* min binary exponent */
  133. #define FLT_NORMALIZE 0
  134. #define FLT_RADIX 2 /* exponent radix */
  135. #define FLT_ROUNDS 1 /* addition rounding: near */
  136. #define LDBL_DIG DBL_DIG /* # of decimal digits of precision */
  137. #define LDBL_EPSILON DBL_EPSILON /* smallest such that 1.0+LDBL_EPSILON != 1.0 */
  138. #define LDBL_MANT_DIG DBL_MANT_DIG /* # of bits in mantissa */
  139. #define LDBL_MAX DBL_MAX /* max value */
  140. #define LDBL_MAX_10_EXP DBL_MAX_10_EXP /* max decimal exponent */
  141. #define LDBL_MAX_EXP DBL_MAX_EXP /* max binary exponent */
  142. #define LDBL_MIN DBL_MIN /* min positive value */
  143. #define LDBL_MIN_10_EXP DBL_MIN_10_EXP /* min decimal exponent */
  144. #define LDBL_MIN_EXP DBL_MIN_EXP /* min binary exponent */
  145. #define _LDBL_RADIX DBL_RADIX /* exponent radix */
  146. #define _LDBL_ROUNDS DBL_ROUNDS /* addition rounding: near */
  147. /* Function prototypes */
  148. _CRTIMP unsigned int __cdecl _clearfp(void);
  149. _CRTIMP unsigned int __cdecl _controlfp(unsigned int,unsigned int);
  150. _CRTIMP unsigned int __cdecl _statusfp(void);
  151. _CRTIMP void __cdecl _fpreset(void);
  152. #define _clear87 _clearfp
  153. #define _status87 _statusfp
  154. /*
  155. * Abstract User Control Word Mask and bit definitions
  156. */
  157. #define _MCW_EM 0x0008001f /* interrupt Exception Masks */
  158. #define _EM_INEXACT 0x00000001 /* inexact (precision) */
  159. #define _EM_UNDERFLOW 0x00000002 /* underflow */
  160. #define _EM_OVERFLOW 0x00000004 /* overflow */
  161. #define _EM_ZERODIVIDE 0x00000008 /* zero divide */
  162. #define _EM_INVALID 0x00000010 /* invalid */
  163. #define _MCW_RC 0x00000300 /* Rounding Control */
  164. #define _RC_NEAR 0x00000000 /* near */
  165. #define _RC_DOWN 0x00000100 /* down */
  166. #define _RC_UP 0x00000200 /* up */
  167. #define _RC_CHOP 0x00000300 /* chop */
  168. /*
  169. * Abstract User Status Word bit definitions
  170. */
  171. #define _SW_INEXACT 0x00000001 /* inexact (precision) */
  172. #define _SW_UNDERFLOW 0x00000002 /* underflow */
  173. #define _SW_OVERFLOW 0x00000004 /* overflow */
  174. #define _SW_ZERODIVIDE 0x00000008 /* zero divide */
  175. #define _SW_INVALID 0x00000010 /* invalid */
  176. /*
  177. * i386 specific definitions
  178. */
  179. #define _MCW_PC 0x00030000 /* Precision Control */
  180. #define _PC_64 0x00000000 /* 64 bits */
  181. #define _PC_53 0x00010000 /* 53 bits */
  182. #define _PC_24 0x00020000 /* 24 bits */
  183. #define _MCW_IC 0x00040000 /* Infinity Control */
  184. #define _IC_AFFINE 0x00040000 /* affine */
  185. #define _IC_PROJECTIVE 0x00000000 /* projective */
  186. #define _EM_DENORMAL 0x00080000 /* denormal exception mask (_control87 only) */
  187. #define _SW_DENORMAL 0x00080000 /* denormal status bit */
  188. _CRTIMP unsigned int __cdecl _control87(unsigned int,unsigned int);
  189. /*
  190. * RISC specific definitions
  191. */
  192. #define _MCW_DN 0x03000000 /* Denormal Control */
  193. #define _DN_SAVE 0x00000000 /* save denormal results and operands */
  194. #define _DN_FLUSH 0x01000000 /* flush denormal results and operands to zero */
  195. #define _DN_FLUSH_OPERANDS_SAVE_RESULTS 0x02000000 /* flush operands to zero and save results */
  196. #define _DN_SAVE_OPERANDS_FLUSH_RESULTS 0x03000000 /* save operands and flush results to zero */
  197. /* initial Control Word value */
  198. #if defined(_M_IX86)
  199. #define _CW_DEFAULT ( _RC_NEAR + _PC_53 + _EM_INVALID + _EM_ZERODIVIDE + _EM_OVERFLOW + _EM_UNDERFLOW + _EM_INEXACT + _EM_DENORMAL)
  200. #elif defined(_M_IA64)
  201. #define _CW_DEFAULT ( _RC_NEAR + _PC_64 + _EM_INVALID + _EM_ZERODIVIDE + _EM_OVERFLOW + _EM_UNDERFLOW + _EM_INEXACT + _EM_DENORMAL)
  202. #elif defined(_M_MRX000) || defined (_M_ALPHA) || defined(_M_PPC)
  203. #define _CW_DEFAULT ( _RC_NEAR + _DN_FLUSH + _EM_INVALID + _EM_ZERODIVIDE + _EM_OVERFLOW + _EM_UNDERFLOW + _EM_INEXACT )
  204. #endif
  205. /* Global variable holding floating point error code */
  206. #if defined(_MT) || defined(_DLL)
  207. _CRTIMP extern int * __cdecl __fpecode(void);
  208. #define _fpecode (*__fpecode())
  209. #else /* ndef _MT && ndef _DLL */
  210. extern int _fpecode;
  211. #endif /* _MT || _DLL */
  212. /* invalid subconditions (_SW_INVALID also set) */
  213. #define _SW_UNEMULATED 0x0040 /* unemulated instruction */
  214. #define _SW_SQRTNEG 0x0080 /* square root of a neg number */
  215. #define _SW_STACKOVERFLOW 0x0200 /* FP stack overflow */
  216. #define _SW_STACKUNDERFLOW 0x0400 /* FP stack underflow */
  217. /* Floating point error signals and return codes */
  218. #define _FPE_INVALID 0x81
  219. #define _FPE_DENORMAL 0x82
  220. #define _FPE_ZERODIVIDE 0x83
  221. #define _FPE_OVERFLOW 0x84
  222. #define _FPE_UNDERFLOW 0x85
  223. #define _FPE_INEXACT 0x86
  224. #define _FPE_UNEMULATED 0x87
  225. #define _FPE_SQRTNEG 0x88
  226. #define _FPE_STACKOVERFLOW 0x8a
  227. #define _FPE_STACKUNDERFLOW 0x8b
  228. #define _FPE_EXPLICITGEN 0x8c /* raise( SIGFPE ); */
  229. /* IEEE recommended functions */
  230. _CRTIMP double __cdecl _copysign (double, double);
  231. _CRTIMP double __cdecl _chgsign (double);
  232. _CRTIMP double __cdecl _scalb(double, long);
  233. _CRTIMP double __cdecl _logb(double);
  234. _CRTIMP double __cdecl _nextafter(double, double);
  235. _CRTIMP int __cdecl _finite(double);
  236. _CRTIMP int __cdecl _isnan(double);
  237. _CRTIMP int __cdecl _fpclass(double);
  238. #define _FPCLASS_SNAN 0x0001 /* signaling NaN */
  239. #define _FPCLASS_QNAN 0x0002 /* quiet NaN */
  240. #define _FPCLASS_NINF 0x0004 /* negative infinity */
  241. #define _FPCLASS_NN 0x0008 /* negative normal */
  242. #define _FPCLASS_ND 0x0010 /* negative denormal */
  243. #define _FPCLASS_NZ 0x0020 /* -0 */
  244. #define _FPCLASS_PZ 0x0040 /* +0 */
  245. #define _FPCLASS_PD 0x0080 /* positive denormal */
  246. #define _FPCLASS_PN 0x0100 /* positive normal */
  247. #define _FPCLASS_PINF 0x0200 /* positive infinity */
  248. #if !__STDC__
  249. /* Non-ANSI names for compatibility */
  250. #define clear87 _clear87
  251. #define status87 _status87
  252. #define control87 _control87
  253. _CRTIMP void __cdecl fpreset(void);
  254. #define DBL_RADIX _DBL_RADIX
  255. #define DBL_ROUNDS _DBL_ROUNDS
  256. #define LDBL_RADIX _LDBL_RADIX
  257. #define LDBL_ROUNDS _LDBL_ROUNDS
  258. #define MCW_EM _MCW_EM
  259. #define EM_INVALID _EM_INVALID
  260. #define EM_DENORMAL _EM_DENORMAL
  261. #define EM_ZERODIVIDE _EM_ZERODIVIDE
  262. #define EM_OVERFLOW _EM_OVERFLOW
  263. #define EM_UNDERFLOW _EM_UNDERFLOW
  264. #define EM_INEXACT _EM_INEXACT
  265. #define MCW_IC _MCW_IC
  266. #define IC_AFFINE _IC_AFFINE
  267. #define IC_PROJECTIVE _IC_PROJECTIVE
  268. #define MCW_RC _MCW_RC
  269. #define RC_CHOP _RC_CHOP
  270. #define RC_UP _RC_UP
  271. #define RC_DOWN _RC_DOWN
  272. #define RC_NEAR _RC_NEAR
  273. #define MCW_PC _MCW_PC
  274. #define PC_24 _PC_24
  275. #define PC_53 _PC_53
  276. #define PC_64 _PC_64
  277. #define CW_DEFAULT _CW_DEFAULT
  278. #define SW_INVALID _SW_INVALID
  279. #define SW_DENORMAL _SW_DENORMAL
  280. #define SW_ZERODIVIDE _SW_ZERODIVIDE
  281. #define SW_OVERFLOW _SW_OVERFLOW
  282. #define SW_UNDERFLOW _SW_UNDERFLOW
  283. #define SW_INEXACT _SW_INEXACT
  284. #define SW_UNEMULATED _SW_UNEMULATED
  285. #define SW_SQRTNEG _SW_SQRTNEG
  286. #define SW_STACKOVERFLOW _SW_STACKOVERFLOW
  287. #define SW_STACKUNDERFLOW _SW_STACKUNDERFLOW
  288. #define FPE_INVALID _FPE_INVALID
  289. #define FPE_DENORMAL _FPE_DENORMAL
  290. #define FPE_ZERODIVIDE _FPE_ZERODIVIDE
  291. #define FPE_OVERFLOW _FPE_OVERFLOW
  292. #define FPE_UNDERFLOW _FPE_UNDERFLOW
  293. #define FPE_INEXACT _FPE_INEXACT
  294. #define FPE_UNEMULATED _FPE_UNEMULATED
  295. #define FPE_SQRTNEG _FPE_SQRTNEG
  296. #define FPE_STACKOVERFLOW _FPE_STACKOVERFLOW
  297. #define FPE_STACKUNDERFLOW _FPE_STACKUNDERFLOW
  298. #define FPE_EXPLICITGEN _FPE_EXPLICITGEN
  299. #endif /* __STDC__ */
  300. #ifdef __cplusplus
  301. }
  302. #endif
  303. #endif /* _INC_FLOAT */