|
|
1.1 root 1: #ident "@(#)sgs-inc:mc68/values.h 2.4.1.1"
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 || M32 || u3b5 || u3b2
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 mc68000
59: /* This code is an ugly *** C R O C K *** to get around the problems
60: ** of cross-compiling float/double constants. The constant in question
61: ** is the maximum float/double value. Since the VAX has a smaller range
62: ** than the MC68000, it cannot convert MAXFLOAT using the native atof().
63: ** What we do here is define a local constant value whose bits are the
64: ** right ones for the MC68000.
65: */
66:
67: #ifndef __VALUE_H__
68: extern double _MaXdOuBlE_;
69: asm(" data 1");
70: asm(" even");
71: asm("_MaXdOuBlE_:");
72: asm(" long 0x7f7fffff");
73: #define __VALUE_H__ /* just do it once */
74: #endif
75: #define MAXFLOAT _MaXdOuBlE_
76: #define MAXDOUBLE _MaXdOuBlE_
77: /* #define MAXFLOAT ((float)3.40282346638528860e+38) */
78: /* #define MAXDOUBLE ((double)3.40282346638528860e+38) */
79: /* MINFLOAT/MINDOUBLE are defined to give the smallest non-denormalized
80: ** value.
81: */
82: #define MINDOUBLE ((double)1.17549435e-38)
83: #define MINFLOAT ((float)MINDOUBLE)
84: #define _IEEE 1
85: #define _DEXPLEN 8
86: #define _HIDDENBIT 1
87: #define DMINEXP (-(DMAXEXP) + 1)
88: #define FMINEXP (-(FMAXEXP) + 1)
89: #define CUBRTHUGE 6981463519622.333
90: #define INV_CUBRTHUGE 1.4323644278729908e-13
91: #endif
92: #if pdp11 || vax
93: #define MAXDOUBLE 1.701411834604692293e+38
94: #define MAXFLOAT ((float)1.701411733192644299e+38)
95: /* The following is kludged because the PDP-11 compilers botch the simple form.
96: The kludge causes the constant to be computed at run-time on the PDP-11,
97: even though it is still "folded" at compile-time on the VAX. */
98: #define MINDOUBLE (0.01 * 2.938735877055718770e-37)
99: #define MINFLOAT ((float)MINDOUBLE)
100: #define _IEEE 0
101: #define _DEXPLEN 8
102: #define _HIDDENBIT 1
103: #define DMINEXP (-DMAXEXP)
104: #define FMINEXP (-FMAXEXP)
105: #endif
106: #if gcos
107: #define MAXDOUBLE 1.7014118346046923171e+38
108: #define MAXFLOAT ((float)1.7014118219281863150e+38)
109: #define MINDOUBLE 2.9387358770557187699e-39
110: #define MINFLOAT ((float)MINDOUBLE)
111: #define _IEEE 0
112: #define _DEXPLEN 8
113: #define _HIDDENBIT 0
114: #define DMINEXP (-(DMAXEXP + 1))
115: #define FMINEXP (-(FMAXEXP + 1))
116: #endif
117: #if u370
118: #define _LENBASE 4
119: #else
120: #define _LENBASE 1
121: #endif
122: #define _EXPBASE (1 << _LENBASE)
123: #define _FEXPLEN 8
124: #define DSIGNIF (BITS(double) - _DEXPLEN + _HIDDENBIT - 1)
125: #define FSIGNIF (BITS(float) - _FEXPLEN + _HIDDENBIT - 1)
126: #if mc68000 /* different because BITS(long) > DSIGNIF */
127: #define DMAXPOWTWO ((double)(1L << DSIGNIF - 1))
128: #else
129: #define DMAXPOWTWO ((double)(1L << BITS(long) - 2) * \
130: (1L << DSIGNIF - BITS(long) + 1))
131: #endif
132: #define FMAXPOWTWO ((float)(1L << FSIGNIF - 1))
133: #define DMAXEXP ((1 << _DEXPLEN - 1) - 1 + _IEEE)
134: #define FMAXEXP ((1 << _FEXPLEN - 1) - 1 + _IEEE)
135: #define LN_MAXDOUBLE (M_LN2 * DMAXEXP)
136: #define LN_MINDOUBLE (M_LN2 * (DMINEXP - 1))
137: #define H_PREC (DSIGNIF % 2 ? (1L << DSIGNIF/2) * M_SQRT2 : 1L << DSIGNIF/2)
138: #define X_EPS (1.0/H_PREC)
139: #define X_PLOSS ((double)(long)(M_PI * H_PREC))
140: #define X_TLOSS (M_PI * DMAXPOWTWO)
141: #define M_LN2 0.69314718055994530942
142: #define M_PI 3.14159265358979323846
143: #define M_SQRT2 1.41421356237309504880
144: #define MAXBEXP DMAXEXP /* for backward compatibility */
145: #define MINBEXP DMINEXP /* for backward compatibility */
146: #define MAXPOWTWO DMAXPOWTWO /* for backward compatibility */
147: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.