home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / detk45he.zip / libc / float.h < prev    next >
Text File  |  1999-03-15  |  13KB  |  311 lines

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