home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / include / float.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-20  |  12.1 KB  |  325 lines

  1. #if (defined(__IBMC__) || defined(__IBMCPP__))
  2. #pragma info( none )
  3. #ifndef __CHKHDR__
  4.    #pragma info( none )
  5. #endif
  6. #pragma info( restore )
  7. #endif
  8.  
  9. #ifndef __float_h
  10.    #define __float_h
  11.  
  12.    #ifdef __cplusplus
  13.       extern "C" {
  14.    #endif
  15.  
  16.    #ifndef  _LNK_CONV
  17.       #ifdef _M_I386
  18.          #define _LNK_CONV   _Optlink
  19.       #else
  20.          #define _LNK_CONV
  21.       #endif
  22.    #endif
  23.  
  24.    #ifndef _IMPORT
  25.       #ifdef __IMPORTLIB__
  26.          #define _IMPORT _Import
  27.       #else
  28.          #define _IMPORT
  29.       #endif
  30.    #endif
  31.  
  32.    /********************************************************************/
  33.    /*  <float.h> header file                                           */
  34.    /*                                                                  */
  35.    /*  VisualAge for C++ for Windows, Version 3.5                      */
  36.    /*    Licensed Material - Property of IBM                           */
  37.    /*                                                                  */
  38.    /*  5801-ARR and Other Materials                                    */
  39.    /*                                                                  */
  40.    /*  (c) Copyright IBM Corp 1991, 1996. All rights reserved.         */
  41.    /*                                                                  */
  42.    /********************************************************************/
  43.  
  44.    #define    FLT_ROUNDS            1   /* 0, 2 and 3 also available on 80387 */
  45.  
  46.    #define    FLT_RADIX             2
  47.  
  48.    #define    FLT_MANT_DIG         24
  49.    #define    DBL_MANT_DIG         53
  50. #ifdef _M_I386
  51.    #define    LDBL_MANT_DIG        64
  52. #else
  53.    #define    LDBL_MANT_DIG       106
  54. #endif
  55.  
  56.    #define    FLT_DIG               6
  57.    #define    DBL_DIG              15
  58. #ifdef _M_I386
  59.    #define    LDBL_DIG             18
  60. #else
  61.    #define    LDBL_DIG             30
  62. #endif
  63.  
  64.    #define    FLT_MIN_EXP      (-125)
  65.    #define    DBL_MIN_EXP     (-1021)
  66. #ifdef _M_I386
  67.    #define    LDBL_MIN_EXP   (-16381)
  68. #endif
  69.  
  70.    #define    FLT_MIN_10_EXP    (-37)
  71.    #define    DBL_MIN_10_EXP   (-307)
  72. #ifdef _M_I386
  73.    #define    LDBL_MIN_10_EXP (-4931)
  74. #endif
  75.  
  76.    #define    FLT_MAX_EXP         128
  77.    #define    DBL_MAX_EXP        1024
  78. #ifdef _M_I386
  79.    #define    LDBL_MAX_EXP      16384
  80. #endif
  81.  
  82.    #define    FLT_MAX_10_EXP       38
  83.    #define    DBL_MAX_10_EXP      308
  84. #ifdef _M_I386
  85.    #define    LDBL_MAX_10_EXP    4932
  86. #endif
  87.  
  88.    #define    FLT_MAX         3.402823466e+38F
  89. #ifdef _M_I386
  90.    #define    DBL_MAX         1.7976931348623158e+308
  91.    #define    LDBL_MAX        1.18973149535723176499e+4932L
  92. #endif
  93.  
  94.    #define    FLT_EPSILON     1.192092896e-07F
  95.    #define    DBL_EPSILON     2.2204460492503131e-016
  96. #ifdef _M_I386
  97.    #define    LDBL_EPSILON    1.08420217248550443401e-19L
  98. #endif
  99.  
  100.    #define    FLT_MIN         1.175494351e-38F
  101.    #define    DBL_MIN         2.2250738585072014e-308
  102. #ifdef _M_I386
  103.    #define    LDBL_MIN        3.36210314311209350626e-4932L
  104. #endif
  105.  
  106. #ifdef __THW_PPC__
  107.    #define    DBL_MAX         1.7976931348623157e+308
  108.    #define LDBL_MANT_DIG      106
  109.    #define LDBL_MIN_EXP       DBL_MIN_EXP
  110.    #define LDBL_MIN           ((long double)DBL_MIN)
  111.    #define LDBL_MIN_10_EXP    DBL_MIN_10_EXP
  112.    #define LDBL_MAX_EXP       DBL_MAX_EXP
  113.    #define LDBL_MAX           0.1797693134862315807937289714053023E+309L
  114.    #define LDBL_MAX_10_EXP    DBL_MAX_10_EXP
  115.    #define LDBL_EPSILON       0.24651903288156618919116517665087070E-31L
  116. #endif
  117.  
  118.  
  119.    #if defined(__EXTENDED__)
  120.  
  121.     #ifdef _M_I386
  122.       /* 80387 math control information */
  123.  
  124.       /* User Control Word Mask and bit definitions. */
  125.       /* These definitions match the 80387 */
  126.  
  127.       #define MCW_EM          0x003f          /* interrupt Exception Masks */
  128.       #define EM_INVALID      0x0001          /*  invalid */
  129.       #define EM_DENORMAL     0x0002          /*  denormal */
  130.       #define EM_ZERODIVIDE   0x0004          /*  zero divide */
  131.       #define EM_OVERFLOW     0x0008          /*  overflow */
  132.       #define EM_UNDERFLOW    0x0010          /*  underflow */
  133.       #define EM_INEXACT      0x0020          /*  inexact (precision) */
  134.  
  135.       #define MCW_IC          0x1000          /* Infinity Control */
  136.       #define IC_AFFINE       0x1000          /*  affine */
  137.       #define IC_PROJECTIVE   0x0000          /*  projective */
  138.  
  139.       #define MCW_RC          0x0c00          /* Rounding Control */
  140.       #define RC_CHOP         0x0c00          /*  chop */
  141.       #define RC_UP           0x0800          /*  up */
  142.       #define RC_DOWN         0x0400          /*  down */
  143.       #define RC_NEAR         0x0000          /*  near */
  144.  
  145.       #define MCW_PC          0x0300          /* Precision Control */
  146.       #define PC_24           0x0000          /*  24 bits */
  147.       #define PC_53           0x0200          /*  53 bits */
  148.       #define PC_64           0x0300          /*  64 bits */
  149.  
  150.       /* initial Control Word value */
  151.  
  152.       #define CW_DEFAULT ( RC_NEAR + PC_64 + EM_DENORMAL + EM_INEXACT )
  153.  
  154.       /* user Status Word bit definitions */
  155.  
  156.       #define SW_INVALID      0x0001          /* invalid */
  157.       #define SW_DENORMAL     0x0002          /* denormal */
  158.       #define SW_ZERODIVIDE   0x0004          /* zero divide */
  159.       #define SW_OVERFLOW     0x0008          /* overflow */
  160.       #define SW_UNDERFLOW    0x0010          /* underflow */
  161.       #define SW_INEXACT      0x0020          /* inexact (precision) */
  162.       #define SW_STACKFAULT   0x0040          /* stack fault (SW_INVALID also set) */
  163.  
  164.       /* stack problems (SW_INVALID and SW_STACKFAULT both set) */
  165.       #define SW_STACKOVERFLOW        0x0200          /* stack overflow */
  166.                                                       /* bit is off for stack underflow */
  167.     #endif
  168.  
  169.     #ifdef __THW_PPC__
  170.       /* FPSCR information on PowerPC */
  171.  
  172.       /* A fpscr_t contains a full FPSCR word which includes */
  173.       /* exception bits, exception enable bits and rounding  */
  174.       /* control bits.                                       */
  175.       typedef unsigned int fpscr_t;
  176.  
  177.       /* Exception mask in the FPSCR control portion */
  178.  
  179.       #define MCW_EM          ((fpscr_t)0x000000FC) /* enable bit summ.    */
  180.       #define EM_INVALID      ((fpscr_t)0x00000080) /* invalid, bit 24     */
  181.       #define EM_OVERFLOW     ((fpscr_t)0x00000040) /* overflow, bit 25    */
  182.       #define EM_UNDERFLOW    ((fpscr_t)0x00000020) /* underflow, bit 26   */
  183.       #define EM_ZERODIVIDE   ((fpscr_t)0x00000010) /* zero divide, bit 27 */
  184.       #define EM_INEXACT      ((fpscr_t)0x00000008) /* inexact, bit 28     */
  185.       #define EM_DENORMAL     ((fpscr_t)0x00000004) /* denormal, bit 29    */
  186.                                                      /* 1 means no denorm   */
  187.                                                      /* numbers.            */
  188.  
  189.       #define MCW_IC          ((fpscr_t) 0x00000000) /* Infinity Control    */
  190.       #define IC_AFFINE       ((fpscr_t) 0x00000000) /* meaningful to PPC.  */
  191.       #define IC_PROJECTIVE   ((fpscr_t) 0x00000000) /* regardless of its   */
  192.                                 /* value, PPC treats infinity in the affine */
  193.                                 /* sense:  -INF < finite number < +INF      */
  194.  
  195.       #define MCW_RC          ((fpscr_t) 0x00000001) /* Rounding Control   */
  196.       #define RC_CHOP         ((fpscr_t) 0x00000001) /* toward zero (chop) */
  197.       #define RC_UP           ((fpscr_t) 0x00000002) /* +infinity (up)     */
  198.       #define RC_DOWN         ((fpscr_t) 0x00000003) /* -infinity (down)   */
  199.       #define RC_NEAR         ((fpscr_t) 0x00000000) /* nearest            */
  200.  
  201.       #define MCW_PC ((fpscr_t)0x00000000) /* Precision control is not     */
  202.       #define PC_24  ((fpscr_t)0x00000000) /* meanningful to PPC. To       */
  203.       #define PC_53  ((fpscr_t)0x00000000) /* maintain the compatibility   */
  204.       #define PC_64  ((fpscr_t)0x00000000) /* they can be programmed.      */
  205.                                            /* However, regardless of its   */
  206.                                            /* value, FP operations are     */
  207.                                            /* done in 64 bits.             */
  208.  
  209.       /* initial Control Word value. */
  210.  
  211.       #define CW_DEFAULT (RC_CHOP + EM_DENORMAL + EM_OVERFLOW + \
  212.                           EM_UNDERFLOW + EM_ZERODIVIDE)
  213.  
  214.  
  215.       /* Status Word portion in FPSCR */
  216.  
  217.       #define SW_FX_SUM       ((fpscr_t) 0x80000000) /* exception summary  */
  218.       #define SW_INVALID      ((fpscr_t) 0x20000000) /* invalid, bit 2     */
  219.       #define SW_DENORMAL     ((fpscr_t) 0x00000000) /* denormal, N/A      */
  220.       #define SW_ZERODIVIDE   ((fpscr_t) 0x04000000) /* zero divide, bit 5 */
  221.       #define SW_OVERFLOW     ((fpscr_t) 0x10000000) /* overflow, bit 3    */
  222.       #define SW_UNDERFLOW    ((fpscr_t) 0x08000000) /* underflow, bit 4   */
  223.       #define SW_INEXACT      ((fpscr_t) 0x02000000) /* inexact, bit 6     */
  224.       #define SW_STACKFAULT   ((fpscr_t) 0x00000000) /* stack fault, N/A   */
  225.  
  226.       #define SW_STACKOVERFLOW ((fpscr_t) 0x00000000) /* stack overflow, N/A */
  227.     #endif
  228.  
  229.       /*  Floating point error signals and return codes */
  230.  
  231.       #define FPE_INTDIV0             0x91            /* integer division by 0 */
  232.       #define FPE_INT_OFLOW           0x92            /* integer overflow */
  233.       #define FPE_BOUND               0x93            /* bounds failure */
  234.       #define FPE_INVALID             0x81
  235.       #define FPE_DENORMAL            0x82
  236.       #define FPE_ZERODIVIDE          0x83
  237.       #define FPE_OVERFLOW            0x84
  238.       #define FPE_UNDERFLOW           0x85
  239.       #define FPE_INEXACT             0x86
  240.  
  241.       #define FPE_STACKOVERFLOW       0x8a
  242.       #define FPE_STACKUNDERFLOW      0x8b
  243.  
  244.       #define FPE_EXPLICITGEN         0x8c    /* raise( SIGFPE ); */
  245.  
  246.       /* function prototypes */
  247.  
  248.     #ifdef _M_I386
  249.       extern unsigned int (_IMPORT _LNK_CONV _clear87)( void );
  250.       extern unsigned int (_IMPORT _LNK_CONV _control87)( unsigned int, unsigned int );
  251.       extern unsigned int (_IMPORT _LNK_CONV _status87)( void );
  252.       extern void          _IMPORT _LNK_CONV _fpreset( void );
  253.  
  254.       unsigned int _Builtin __clear87( void );
  255.       unsigned int _Builtin __control87( unsigned int, unsigned int );
  256.       unsigned int _Builtin __status87( void );
  257.  
  258.       #define _clear87( )             __clear87( )
  259.       #define _control87( x, y )      __control87( (x), (y) )
  260.       #define _status87( )            __status87( )
  261.  
  262.       extern const float  _IMPORT _fposinfi;
  263.       #define _INFF       _fposinfi
  264.       #define _INFINITYF  _fposinfi
  265.  
  266.       extern const double _IMPORT _infinity;
  267.       #define _INF        _infinity
  268.       #define _INFINITY   _infinity
  269.  
  270.       extern const long double _IMPORT _ldposinfi;
  271.       #define _INFL            _ldposinfi
  272.       #define _INFINITYL       _ldposinfi
  273.  
  274.       extern const float       _IMPORT _fposqnan;
  275.       extern const double      _IMPORT _dposqnan;
  276.       extern const long double _IMPORT _ldposqnan;
  277.  
  278.       #define _NANF      _fposqnan
  279.       #define _NAN       _dposqnan
  280.       #define _NANL      _ldposqnan
  281.     #else
  282.       extern unsigned int  _clear87( void );
  283.       extern unsigned int  _control87( unsigned int, unsigned int );
  284.       extern unsigned int  _status87( void );
  285.       extern void          _fpreset( void );
  286.  
  287.       extern const float   _fposinfi;
  288.       #define _INFF        _fposinfi
  289.       #define _INFINITYF   _fposinfi
  290.  
  291.       extern const double _infinity;
  292.       #define _INF        _infinity
  293.       #define _INFINITY   _infinity
  294.  
  295.       extern const long double _ldposinfi;
  296.       #define _INFL       _ldposinfi
  297.       #define _INFINITYL  _ldposinfi
  298.  
  299.       extern const float       _fposqnan;
  300.       extern const double      _dposqnan;
  301.       extern const long double _ldposqnan;
  302.  
  303.       #define _NANF      _fposqnan
  304.       #define _NAN       _dposqnan
  305.       #define _NANL      _ldposqnan
  306.     #endif
  307.  
  308.    #endif
  309.  
  310.    #ifdef __cplusplus
  311.       }
  312.    #endif
  313.  
  314. #endif
  315.  
  316. #if (defined(__IBMC__) || defined(__IBMCPP__))
  317. #pragma info( none )
  318. #ifndef __CHKHDR__
  319.    #pragma info( restore )
  320. #endif
  321. #pragma info( restore )
  322. #endif
  323.  
  324.  
  325.