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.

358 lines
10 KiB

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