1 /* Begin include file values.h */
 2 /*        @(#)values.h        1.16      */
 3 
 4 #ifndef BITSPERBYTE
 5 /* These values work with any binary representation of integers
 6  * where the high-order bit contains the sign. */
 7 
 8 /* a number used normally for size of a shift */
 9 #define BITSPERBYTE 9
10 
11 #define BITS(type)  (BITSPERBYTE * (int)sizeof(type))
12 
13 /* short, regular and long ints with only the high-order bit turned on */
14 #define HIBITS      ((short)(1 << BITS(short) - 1))
15 #define HIBITI      (1 << BITS(int) - 1)
16 #define HIBITL      (1L << BITS(long) - 1)
17 
18 /* largest short, regular and long int */
19 #define MAXSHORT ((short)~HIBITS)
20 #define MAXINT      (~HIBITI)
21 #define MAXLONG     (~HIBITL)
22 
23 /* various values that describe the binary floating-point representation
24  * _EXPBASE         - the exponent base
25  * DMAXEXP          - the maximum exponent of a double (as returned by frexp())
26  * FMAXEXP          - the maximum exponent of a float  (as returned by frexp())
27  * DMINEXP          - the minimum exponent of a double (as returned by frexp())
28  * FMINEXP          - the minimum exponent of a float  (as returned by frexp())
29  * MAXDOUBLE        - the largest double
30                               ((_EXPBASE ** DMAXEXP) * (1 - (_EXPBASE ** -DSIGNIF)))
31  * MAXFLOAT         - the largest float
32                               ((_EXPBASE ** FMAXEXP) * (1 - (_EXPBASE ** -FSIGNIF)))
33  * MINDOUBLE        - the smallest double (_EXPBASE ** (DMINEXP - 1))
34  * MINFLOAT         - the smallest float (_EXPBASE ** (FMINEXP - 1))
35  * DSIGNIF          - the number of significant bits in a double
36  * FSIGNIF          - the number of significant bits in a float
37  * DMAXPOWTWO       - the largest power of two exactly representable as a double
38  * FMAXPOWTWO       - the largest power of two exactly representable as a float
39  * _IEEE  - 1 if IEEE standard representation is used
40  * _DEXPLEN         - the number of bits for the exponent of a double
41  * _FEXPLEN         - the number of bits for the exponent of a float
42  * _HIDDENBIT       - 1 if high-significance bit of mantissa is implicit
43  * LN_MAXDOUBLE     - the natural log of the largest double  -- log(MAXDOUBLE)
44  * LN_MINDOUBLE     - the natural log of the smallest double -- log(MINDOUBLE)
45  */
46 #define MAXDOUBLE   1.7014118346046923171e+38
47 #define MAXFLOAT    ((float)1.7014118219281863150e+38)
48 #define MINDOUBLE   2.9387358770557187699e-39
49 #define MINFLOAT    ((float)MINDOUBLE)
50 #define _IEEE                 0
51 #define _DEXPLEN    8
52 #define _HIDDENBIT  0
53 #define DMINEXP     (-(DMAXEXP + 1))
54 #define FMINEXP     (-(FMAXEXP + 1))
55 
56 #define _EXPBASE    (1 << _LENBASE)
57 #define _FEXPLEN    8
58 #define DSIGNIF     (BITS(double) - _DEXPLEN + _HIDDENBIT - 1)
59 #define FSIGNIF     (BITS(float)  - _FEXPLEN + _HIDDENBIT - 1)
60 /*#define DMAXPOWTWO          ((double)(1L << BITS(long) - 2) * \
61                                         (1L << DSIGNIF - BITS(long) + 1)) */
62 #define DMAXPOWTWO  ((double)(1L << DSIGNIF -1))
63 #define FMAXPOWTWO  ((float)(1L << FSIGNIF - 1))
64 #define DMAXEXP     ((1 << _DEXPLEN - 1) - 1 + _IEEE)
65 #define FMAXEXP     ((1 << _FEXPLEN - 1) - 1 + _IEEE)
66 #define LN_MAXDOUBLE          (M_LN2 * DMAXEXP)
67 #define LN_MINDOUBLE          (M_LN2 * (DMINEXP - 1))
68 #define H_PREC      (DSIGNIF % 2 ? (1L << DSIGNIF/2) * M_SQRT2 : 1L << DSIGNIF/2)
69 #define X_EPS       (1.0/H_PREC)
70 #define X_PLOSS     ((double)(long)(M_PI * H_PREC))
71 #define X_TLOSS     (M_PI * DMAXPOWTWO)
72 #define M_LN2       0.69314718055994530941723
73 #define M_PI        3.1415926535897932384626
74 #define M_SQRT2     1.4142135623730950488017
75 #define MAXBEXP     DMAXEXP /* for backward compatibility */
76 #define MINBEXP     DMINEXP /* for backward compatibility */
77 #define MAXPOWTWO   DMAXPOWTWO /* for backward compatibility */
78 #endif
79 
80 /* End include file values.h */