1 | /*
|
---|
2 | =============================================================================
|
---|
3 | values.h -- values for arithmetic functions
|
---|
4 | Version 7 -- 1987-12-16 -- D.N. Lynx Crowe
|
---|
5 | =============================================================================
|
---|
6 | */
|
---|
7 |
|
---|
8 | #ifndef BITSPERBYTE
|
---|
9 |
|
---|
10 | #define gcos 0
|
---|
11 | #define m68k 1
|
---|
12 | #define pdp11 0
|
---|
13 | #define u3b 0
|
---|
14 | #define u3b5 0
|
---|
15 | #define u370 0
|
---|
16 | #define vax 0
|
---|
17 |
|
---|
18 | /* These values work with any binary representation of integers
|
---|
19 | * where the high-order bit contains the sign. */
|
---|
20 |
|
---|
21 | /* a number used normally for size of a shift */
|
---|
22 |
|
---|
23 | #if gcos
|
---|
24 | #define BITSPERBYTE 9
|
---|
25 | #else
|
---|
26 | #define BITSPERBYTE 8
|
---|
27 | #endif
|
---|
28 |
|
---|
29 | #define BITS(type) (BITSPERBYTE * (int)sizeof(type))
|
---|
30 |
|
---|
31 | /* short, regular and long ints with only the high-order bit turned on */
|
---|
32 |
|
---|
33 | #define HIBITS ((short)(1 << BITS(short) - 1))
|
---|
34 | #define HIBITI (1 << BITS(int) - 1)
|
---|
35 | #define HIBITL (1L << BITS(long) - 1)
|
---|
36 |
|
---|
37 | /* largest short, regular and long int */
|
---|
38 |
|
---|
39 | #define MAXSHORT ((short)~HIBITS)
|
---|
40 | #define MAXINT (~HIBITI)
|
---|
41 | #define MAXLONG (~HIBITL)
|
---|
42 |
|
---|
43 | /* various values that describe the binary floating-point representation
|
---|
44 |
|
---|
45 | * _EXPBASE - the exponent base
|
---|
46 | * DMAXEXP - the maximum exponent of a double (as returned by frexp())
|
---|
47 | * FMAXEXP - the maximum exponent of a float (as returned by frexp())
|
---|
48 | * DMINEXP - the minimum exponent of a double (as returned by frexp())
|
---|
49 | * FMINEXP - the minimum exponent of a float (as returned by frexp())
|
---|
50 | * MAXDOUBLE - the largest double
|
---|
51 | ((_EXPBASE ** DMAXEXP) * (1 - (_EXPBASE ** -DSIGNIF)))
|
---|
52 | * MAXFLOAT - the largest float
|
---|
53 | ((_EXPBASE ** FMAXEXP) * (1 - (_EXPBASE ** -FSIGNIF)))
|
---|
54 | * MINDOUBLE - the smallest double (_EXPBASE ** (DMINEXP - 1))
|
---|
55 | * MINFLOAT - the smallest float (_EXPBASE ** (FMINEXP - 1))
|
---|
56 | * DSIGNIF - the number of significant bits in a double
|
---|
57 | * FSIGNIF - the number of significant bits in a float
|
---|
58 | * DMAXPOWTWO - the largest power of two exactly representable as a double
|
---|
59 | * FMAXPOWTWO - the largest power of two exactly representable as a float
|
---|
60 | * _IEEE - 1 if IEEE standard representation is used
|
---|
61 | * _DEXPLEN - the number of bits for the exponent of a double
|
---|
62 | * _FEXPLEN - the number of bits for the exponent of a float
|
---|
63 | * _HIDDENBIT - 1 if high-significance bit of mantissa is implicit
|
---|
64 | * LN_MAXDOUBLE - the natural log of the largest double -- log(MAXDOUBLE)
|
---|
65 | * LN_MINDOUBLE - the natural log of the smallest double -- log(MINDOUBLE)
|
---|
66 | */
|
---|
67 |
|
---|
68 | #if u3b || u3b5 || m68k
|
---|
69 | #define MAXDOUBLE 1.79769313486231470e+308
|
---|
70 | #define MAXFLOAT ((float)3.40282346638528860e+38)
|
---|
71 | #define MINDOUBLE 4.94065645841246544e-324
|
---|
72 | #define MINFLOAT ((float)1.40129846432481707e-45)
|
---|
73 | #define _IEEE 1
|
---|
74 | #define _DEXPLEN 11
|
---|
75 | #define _HIDDENBIT 1
|
---|
76 | #define DMINEXP (-(DMAXEXP + DSIGNIF - _HIDDENBIT - 3))
|
---|
77 | #define FMINEXP (-(FMAXEXP + FSIGNIF - _HIDDENBIT - 3))
|
---|
78 | #endif
|
---|
79 |
|
---|
80 | #if pdp11 || vax
|
---|
81 | #define MAXDOUBLE 1.701411834604692293e+38
|
---|
82 | #define MAXFLOAT ((float)1.701411733192644299e+38)
|
---|
83 |
|
---|
84 | /* The following is kludged because the PDP-11 compilers botch the simple form.
|
---|
85 | The kludge causes the constant to be computed at run-time on the PDP-11,
|
---|
86 | even though it is still "folded" at compile-time on the VAX. */
|
---|
87 |
|
---|
88 | #define MINDOUBLE (0.01 * 2.938735877055718770e-37)
|
---|
89 | #define MINFLOAT ((float)MINDOUBLE)
|
---|
90 | #define _IEEE 0
|
---|
91 | #define _DEXPLEN 8
|
---|
92 | #define _HIDDENBIT 1
|
---|
93 | #define DMINEXP (-DMAXEXP)
|
---|
94 | #define FMINEXP (-FMAXEXP)
|
---|
95 | #endif
|
---|
96 |
|
---|
97 | #if gcos
|
---|
98 | #define MAXDOUBLE 1.7014118346046923171e+38
|
---|
99 | #define MAXFLOAT ((float)1.7014118219281863150e+38)
|
---|
100 | #define MINDOUBLE 2.9387358770557187699e-39
|
---|
101 | #define MINFLOAT ((float)MINDOUBLE)
|
---|
102 | #define _IEEE 0
|
---|
103 | #define _DEXPLEN 8
|
---|
104 | #define _HIDDENBIT 0
|
---|
105 | #define DMINEXP (-(DMAXEXP + 1))
|
---|
106 | #define FMINEXP (-(FMAXEXP + 1))
|
---|
107 | #endif
|
---|
108 |
|
---|
109 | #if u370
|
---|
110 | #define _LENBASE 4
|
---|
111 | #else
|
---|
112 | #define _LENBASE 1
|
---|
113 | #endif
|
---|
114 |
|
---|
115 | #define _EXPBASE (1 << _LENBASE)
|
---|
116 | #define _FEXPLEN 8
|
---|
117 | #define DSIGNIF (BITS(double) - _DEXPLEN + _HIDDENBIT - 1)
|
---|
118 | #define FSIGNIF (BITS(float) - _FEXPLEN + _HIDDENBIT - 1)
|
---|
119 | #define DMAXPOWTWO ((double)(1L<<BITS(long)-2)*(1L<<DSIGNIF-BITS(long)+1))
|
---|
120 | #define FMAXPOWTWO ((float)(1L << FSIGNIF - 1))
|
---|
121 | #define DMAXEXP ((1 << _DEXPLEN - 1) - 1 + _IEEE)
|
---|
122 | #define FMAXEXP ((1 << _FEXPLEN - 1) - 1 + _IEEE)
|
---|
123 | #define LN_MAXDOUBLE (M_LN2 * DMAXEXP)
|
---|
124 | #define LN_MINDOUBLE (M_LN2 * (DMINEXP - 1))
|
---|
125 | #define H_PREC (DSIGNIF % 2 ? (1L << DSIGNIF/2) * M_SQRT2 : 1L << DSIGNIF/2)
|
---|
126 | #define X_EPS (1.0/H_PREC)
|
---|
127 | #define X_PLOSS ((double)(long)(M_PI * H_PREC))
|
---|
128 | #define X_TLOSS (M_PI * DMAXPOWTWO)
|
---|
129 | #define M_LN2 0.69314718055994530942
|
---|
130 | #define M_PI 3.14159265358979323846
|
---|
131 | #define M_SQRT2 1.41421356237309504880
|
---|
132 | #define MAXBEXP DMAXEXP /* for backward compatibility */
|
---|
133 | #define MINBEXP DMINEXP /* for backward compatibility */
|
---|
134 | #define MAXPOWTWO DMAXPOWTWO /* for backward compatibility */
|
---|
135 |
|
---|
136 | #endif
|
---|