home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / famapi.zip / INCLUDE.ZIP / FLOAT.H < prev    next >
C/C++ Source or Header  |  1993-06-13  |  5KB  |  137 lines

  1. //
  2. //      **************************************************************
  3. //       JdeBP C++ Library Routines      General Public Licence v1.00
  4. //          Copyright (c) 1991,1992  Jonathan de Boyne Pollard
  5. //      **************************************************************
  6. //
  7. // FLOATING POINT (ANSI)
  8. //
  9.  
  10. //
  11. //  None of these are carved in stone until the MATHx.LIB libraries are
  12. //  fully tested for 16-bit OS/2 (which emulates the co-processor
  13. //  automatically).
  14. //
  15.  
  16. #if !defined(___STDDEF_H_INCLUDED)
  17. #include <_stddef.h>
  18. #endif
  19.  
  20. #define DBL_DIG     15          /* # of decimal digits of precision */
  21. #define DBL_EPSILON 2.2204460492503131e-016 /* smallest such that 1.0+DBL_EPSILON != 1.0 */
  22. #define DBL_MANT_DIG    53          /* # of bits in mantissa */
  23. #define DBL_MAX     1.7976931348623158e+308 /* max value */
  24. #define DBL_MAX_10_EXP  308         /* max decimal exponent */
  25. #define DBL_MAX_EXP 1024            /* max binary exponent */
  26. #define DBL_MIN     2.2250738585072014e-308 /* min positive value */
  27. #define DBL_MIN_10_EXP  (-307)          /* min decimal exponent */
  28. #define DBL_MIN_EXP (-1021)         /* min binary exponent */
  29. #define DBL_RADIX   2           /* exponent radix */
  30. #define DBL_ROUNDS  1           /* addition rounding: near */
  31.  
  32. #define FLT_DIG     7           /* # of decimal digits of precision */
  33. #define FLT_EPSILON 1.192092896e-07F    /* smallest such that 1.0+FLT_EPSILON != 1.0 */
  34. #define FLT_GUARD   0
  35. #define FLT_MANT_DIG    24          /* # of bits in mantissa */
  36. #define FLT_MAX     3.402823466e+38F    /* max value */
  37. #define FLT_MAX_10_EXP  38          /* max decimal exponent */
  38. #define FLT_MAX_EXP 128         /* max binary exponent */
  39. #define FLT_MIN     1.175494351e-38F    /* min positive value */
  40. #define FLT_MIN_10_EXP  (-37)           /* min decimal exponent */
  41. #define FLT_MIN_EXP (-125)          /* min binary exponent */
  42. #define FLT_NORMALIZE   0
  43. #define FLT_RADIX   2           /* exponent radix */
  44. #define FLT_ROUNDS  1           /* addition rounding: near */
  45.  
  46. #define LDBL_DIG    19          /* # of decimal digits of precision */
  47. #define LDBL_EPSILON    5.4210108624275221706e-020  /* smallest such that 1.0+LDBL_EPSILON != 1.0 */
  48. #define LDBL_MANT_DIG   64          /* # of bits in mantissa */
  49. #define LDBL_MAX    1.189731495357231765e+4932L /* max value */
  50. #define LDBL_MAX_10_EXP 4932            /* max decimal exponent */
  51. #define LDBL_MAX_EXP    16384           /* max binary exponent */
  52. #define LDBL_MIN    3.3621031431120935063e-4932L /* min positive value */
  53. #define LDBL_MIN_10_EXP (-4931)         /* min decimal exponent */
  54. #define LDBL_MIN_EXP    (-16381)        /* min binary exponent */
  55. #define LDBL_RADIX  2           /* exponent radix */
  56. #define LDBL_ROUNDS 1           /* addition rounding: near */
  57.  
  58.  
  59. /*
  60.  *  8087/80287 math control information
  61.  */
  62.  
  63.  
  64. /* User Control Word Mask and bit definitions.
  65.  * These definitions match the 8087/80287
  66.  */
  67.  
  68. #define MCW_EM      0x003f      /* interrupt Exception Masks */
  69. #define EM_INVALID  0x0001      /*   invalid */
  70. #define EM_DENORMAL 0x0002      /*   denormal */
  71. #define EM_ZERODIVIDE   0x0004      /*   zero divide */
  72. #define EM_OVERFLOW 0x0008      /*   overflow */
  73. #define EM_UNDERFLOW    0x0010      /*   underflow */
  74. #define EM_INEXACT  0x0020      /*   inexact (precision) */
  75.  
  76. #define MCW_IC      0x1000      /* Infinity Control */
  77. #define IC_AFFINE   0x1000      /*   affine */
  78. #define IC_PROJECTIVE   0x0000      /*   projective */
  79.  
  80. #define MCW_RC      0x0c00      /* Rounding Control */
  81. #define RC_CHOP     0x0c00      /*   chop */
  82. #define RC_UP       0x0800      /*   up */
  83. #define RC_DOWN     0x0400      /*   down */
  84. #define RC_NEAR     0x0000      /*   near */
  85.  
  86. #define MCW_PC      0x0300      /* Precision Control */
  87. #define PC_24       0x0000      /*    24 bits */
  88. #define PC_53       0x0200      /*    53 bits */
  89. #define PC_64       0x0300      /*    64 bits */
  90.  
  91.  
  92. /* initial Control Word value */
  93.  
  94. #define CW_DEFAULT ( IC_AFFINE + RC_NEAR + PC_64 + EM_DENORMAL + EM_UNDERFLOW + EM_INEXACT )
  95.  
  96.  
  97. /* user Status Word bit definitions */
  98.  
  99. #define SW_INVALID  0x0001  /* invalid */
  100. #define SW_DENORMAL 0x0002  /* denormal */
  101. #define SW_ZERODIVIDE   0x0004  /* zero divide */
  102. #define SW_OVERFLOW 0x0008  /* overflow */
  103. #define SW_UNDERFLOW    0x0010  /* underflow */
  104. #define SW_INEXACT  0x0020  /* inexact (precision) */
  105.  
  106.  
  107. /* invalid subconditions (SW_INVALID also set) */
  108.  
  109. #define SW_UNEMULATED       0x0040  /* unemulated instruction */
  110. #define SW_SQRTNEG      0x0080  /* square root of a neg number */
  111. #define SW_STACKOVERFLOW    0x0200  /* FP stack overflow */
  112. #define SW_STACKUNDERFLOW   0x0400  /* FP stack underflow */
  113.  
  114.  
  115. /*  Floating point error signals and return codes */
  116.  
  117. #define FPE_INVALID     0x81
  118. #define FPE_DENORMAL        0x82
  119. #define FPE_ZERODIVIDE      0x83
  120. #define FPE_OVERFLOW        0x84
  121. #define FPE_UNDERFLOW       0x85
  122. #define FPE_INEXACT     0x86
  123.  
  124. #define FPE_UNEMULATED      0x87
  125. #define FPE_SQRTNEG     0x88
  126. #define FPE_STACKOVERFLOW   0x8a
  127. #define FPE_STACKUNDERFLOW  0x8b
  128.  
  129. #define FPE_EXPLICITGEN     0x8c    /* raise( SIGFPE ); */
  130.  
  131. /* function prototypes */
  132.  
  133. unsigned int _FAR_ _cdecl _clear87(void);
  134. unsigned int _FAR_ _cdecl _control87(unsigned int, unsigned int);
  135. void _FAR_ _cdecl _fpreset(void);
  136. unsigned int _FAR_ _cdecl _status87(void);
  137.