home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 June / Chip_2002-06_cd1.bin / zkuste / cecko / install / devcpp4920.exe / include / float.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-09-17  |  6.1 KB  |  220 lines

  1. /* 
  2.  * float.h
  3.  *
  4.  * Constants related to floating point arithmetic.
  5.  *
  6.  * Also included here are some non-ANSI bits for accessing the floating
  7.  * point controller.
  8.  *
  9.  * NOTE: GCC provides float.h, and it is probably more accurate than this,
  10.  *       but it doesn't include the non-standard stuff for accessing the
  11.  *       fp controller. (TODO: Move those bits elsewhere?) Thus it is
  12.  *       probably not a good idea to use the GCC supplied version instead
  13.  *       of this header.
  14.  *
  15.  * This file is part of the Mingw32 package.
  16.  *
  17.  * Contributors:
  18.  *  Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
  19.  *
  20.  *  THIS SOFTWARE IS NOT COPYRIGHTED
  21.  *
  22.  *  This source code is offered for use in the public domain. You may
  23.  *  use, modify or distribute it freely.
  24.  *
  25.  *  This code is distributed in the hope that it will be useful but
  26.  *  WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
  27.  *  DISCLAMED. This includes but is not limited to warranties of
  28.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  29.  *
  30.  * $Revision: 1.5 $
  31.  * $Author: cgf $
  32.  * $Date: 2000/02/05 04:04:54 $
  33.  *
  34.  */
  35.  
  36. #ifndef _FLOAT_H_
  37. #define _FLOAT_H_
  38.  
  39. /* All the headers include this file. */
  40. #include <_mingw.h>
  41.  
  42. #define FLT_ROUNDS    1
  43. #define FLT_GUARD    1
  44. #define FLT_NORMALIZE    1
  45.  
  46. /*
  47.  * The characteristics of float.
  48.  */
  49.  
  50. /* The radix for floating point representation. */
  51. #define FLT_RADIX    2
  52.  
  53. /* Decimal digits of precision. */
  54. #define FLT_DIG        6
  55.  
  56. /* Smallest number such that 1+x != 1 */
  57. #define FLT_EPSILON    1.19209290e-07F
  58.  
  59. /* The number of base FLT_RADIX digits in the mantissa. */
  60. #define FLT_MANT_DIG    24
  61.  
  62. /* The maximum floating point number. */
  63. #define FLT_MAX        3.40282347e+38F
  64.  
  65. /* Maximum n such that FLT_RADIX^n - 1 is representable. */
  66. #define FLT_MAX_EXP    128
  67.  
  68. /* Maximum n such that 10^n is representable. */
  69. #define FLT_MAX_10_EXP    38
  70.  
  71. /* Minimum normalized floating-point number. */
  72. #define FLT_MIN        1.17549435e-38F
  73.  
  74. /* Minimum n such that FLT_RADIX^n is a normalized number. */
  75. #define FLT_MIN_EXP    (-125)
  76.  
  77. /* Minimum n such that 10^n is a normalized number. */
  78. #define FLT_MIN_10_EXP    (-37)
  79.  
  80.  
  81. /*
  82.  * The characteristics of double.
  83.  */
  84. #define DBL_DIG        15
  85. #define DBL_EPSILON    1.1102230246251568e-16
  86. #define DBL_MANT_DIG    53
  87. #define DBL_MAX        1.7976931348623157e+308
  88. #define DBL_MAX_EXP    1024
  89. #define DBL_MAX_10_EXP    308
  90. #define DBL_MIN        2.2250738585072014e-308
  91. #define DBL_MIN_EXP    (-1021)
  92. #define DBL_MIN_10_EXP    (-307)
  93.  
  94.  
  95. /*
  96.  * The characteristics of long double.
  97.  * NOTE: long double is the same as double.
  98.  */
  99. #define LDBL_DIG    15
  100. #define LDBL_EPSILON    1.1102230246251568e-16L
  101. #define LDBL_MANT_DIG    53
  102. #define LDBL_MAX    1.7976931348623157e+308L
  103. #define LDBL_MAX_EXP    1024
  104. #define LDBL_MAX_10_EXP    308
  105. #define LDBL_MIN    2.2250738585072014e-308L
  106. #define LDBL_MIN_EXP    (-1021)
  107. #define LDBL_MIN_10_EXP    (-307)
  108.  
  109.  
  110. /*
  111.  * Functions and definitions for controlling the FPU.
  112.  */
  113. #ifndef    __STRICT_ANSI__
  114.  
  115. /* TODO: These constants are only valid for x86 machines */
  116.  
  117. /* Control word masks for unMask */
  118. #define    _MCW_EM        0x0008001F    /* Error masks */
  119. #define    _MCW_IC        0x00040000    /* Infinity */
  120. #define    _MCW_RC        0x00000300    /* Rounding */
  121. #define    _MCW_PC        0x00030000    /* Precision */
  122.  
  123. /* Control word values for unNew (use with related unMask above) */
  124. #define    _EM_INVALID    0x00000010
  125. #define    _EM_DENORMAL    0x00080000
  126. #define    _EM_ZERODIVIDE    0x00000008
  127. #define    _EM_OVERFLOW    0x00000004
  128. #define    _EM_UNDERFLOW    0x00000002
  129. #define    _EM_INEXACT    0x00000001
  130. #define    _IC_AFFINE    0x00040000
  131. #define    _IC_PROJECTIVE    0x00000000
  132. #define    _RC_CHOP    0x00000300
  133. #define    _RC_UP        0x00000200
  134. #define    _RC_DOWN    0x00000100
  135. #define    _RC_NEAR    0x00000000
  136. #define    _PC_24        0x00020000
  137. #define    _PC_53        0x00010000
  138. #define    _PC_64        0x00000000
  139.  
  140. /* Return values for fpclass. */
  141. #define    _FPCLASS_SNAN    0x0001    /* Signaling "Not a Number" */
  142. #define    _FPCLASS_QNAN    0x0002    /* Quiet "Not a Number" */
  143. #define    _FPCLASS_NINF    0x0004    /* Negative Infinity */
  144. #define    _FPCLASS_NN    0x0008    /* Negative Normal */
  145. #define    _FPCLASS_ND    0x0010    /* Negative Denormal */
  146. #define    _FPCLASS_NZ    0x0020    /* Negative Zero */
  147. #define    _FPCLASS_PZ    0x0040    /* Positive Zero */
  148. #define    _FPCLASS_PD    0x0080    /* Positive Denormal */
  149. #define    _FPCLASS_PN    0x0100    /* Positive Normal */
  150. #define    _FPCLASS_PINF    0x0200    /* Positive Infinity */
  151.  
  152. /* invalid subconditions (_SW_INVALID also set) */
  153. #define _SW_UNEMULATED        0x0040  /* unemulated instruction */
  154. #define _SW_SQRTNEG        0x0080  /* square root of a neg number */
  155. #define _SW_STACKOVERFLOW    0x0200  /* FP stack overflow */
  156. #define _SW_STACKUNDERFLOW    0x0400  /* FP stack underflow */
  157.  
  158. /*  Floating point error signals and return codes */
  159. #define _FPE_INVALID        0x81
  160. #define _FPE_DENORMAL        0x82
  161. #define _FPE_ZERODIVIDE        0x83
  162. #define _FPE_OVERFLOW        0x84
  163. #define _FPE_UNDERFLOW        0x85
  164. #define _FPE_INEXACT        0x86
  165. #define _FPE_UNEMULATED        0x87
  166. #define _FPE_SQRTNEG        0x88
  167. #define _FPE_STACKOVERFLOW    0x8a
  168. #define _FPE_STACKUNDERFLOW    0x8b
  169. #define _FPE_EXPLICITGEN    0x8c    /* raise( SIGFPE ); */
  170.  
  171. #ifndef RC_INVOKED
  172.  
  173. #ifdef    __cplusplus
  174. extern "C" {
  175. #endif
  176.  
  177. /* Set the FPU control word as cw = (cw & ~unMask) | (unNew & unMask),
  178.  * i.e. change the bits in unMask to have the values they have in unNew,
  179.  * leaving other bits unchanged. */
  180. unsigned int    _controlfp (unsigned int unNew, unsigned int unMask);
  181. unsigned int    _control87 (unsigned int unNew, unsigned int unMask);
  182.  
  183.  
  184. unsigned int    _clearfp ();    /* Clear the FPU status word */
  185. unsigned int    _statusfp ();    /* Report the FPU status word */
  186. #define        _clear87    _clearfp
  187. #define        _status87    _statusfp
  188.  
  189. void        _fpreset ();    /* Reset the FPU */
  190. void        fpreset ();
  191.  
  192. /* Global 'variable' for the current floating point error code. */
  193. int *    __fpecode();
  194. #define    _fpecode    (*(__fpecode()))
  195.  
  196. /*
  197.  * IEEE recommended functions
  198.  */
  199.  
  200. double    _chgsign    (double);
  201. double    _copysign    (double, double);
  202. double    _logb        (double);
  203. double    _nextafter    (double, double);
  204. double    _scalb        (double, long);
  205.  
  206. int    _finite        (double);
  207. int    _fpclass    (double);
  208. int    _isnan        (double);
  209.  
  210. #ifdef    __cplusplus
  211. }
  212. #endif
  213.  
  214. #endif    /* Not RC_INVOKED */
  215.  
  216. #endif    /* Not __STRICT_ANSI__ */
  217.  
  218. #endif /* _FLOAT_H_ */
  219.  
  220.