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