1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 1989 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*      Copyright (c) 1984 AT&T */
28 /*        All Rights Reserved   */
29 
30 #ifndef _values_h
31 #define _values_h
32 
33 /* hardcoded --jrmarino */
34 #define bsdmachine	1
35 
36 /* These values work with any binary representation of integers
37  * where the high-order bit contains the sign. */
38 
39 /* a number used normally for size of a shift */
40 #if gcos
41 #define BITSPERBYTE	9
42 #else
43 #define BITSPERBYTE	8
44 #endif
45 #define BITS(type)	(BITSPERBYTE * (int)sizeof(type))
46 
47 /* short, regular and long ints with only the high-order bit turned on */
48 #define HIBITS	((short)(1 << BITS(short) - 1))
49 #define HIBITI	(1U << BITS(int) - 1)
50 #define HIBITL	(1UL << BITS(long) - 1)
51 
52 /* largest short, regular and long int */
53 #define MAXSHORT	((short)~HIBITS)
54 #define MAXINT	((int)~HIBITI)
55 #define MAXLONG	((long)~HIBITL)
56 
57 /* various values that describe the binary floating-point representation
58  * _EXPBASE	- the exponent base
59  * DMAXEXP 	- the maximum exponent of a double (as returned by frexp())
60  * FMAXEXP 	- the maximum exponent of a float  (as returned by frexp())
61  * DMINEXP 	- the minimum exponent of a double (as returned by frexp())
62  * FMINEXP 	- the minimum exponent of a float  (as returned by frexp())
63  * MAXDOUBLE	- the largest double
64 			((_EXPBASE ** DMAXEXP) * (1 - (_EXPBASE ** -DSIGNIF)))
65  * MAXFLOAT	- the largest float
66 			((_EXPBASE ** FMAXEXP) * (1 - (_EXPBASE ** -FSIGNIF)))
67  * MINDOUBLE	- the smallest double (_EXPBASE ** (DMINEXP - 1))
68  * MINFLOAT	- the smallest float (_EXPBASE ** (FMINEXP - 1))
69  * DSIGNIF	- the number of significant bits in a double
70  * FSIGNIF	- the number of significant bits in a float
71  * DMAXPOWTWO	- the largest power of two exactly representable as a double
72  * FMAXPOWTWO	- the largest power of two exactly representable as a float
73  * _IEEE	- 1 if IEEE standard representation is used
74  * _DEXPLEN	- the number of bits for the exponent of a double
75  * _FEXPLEN	- the number of bits for the exponent of a float
76  * _HIDDENBIT	- 1 if high-significance bit of mantissa is implicit
77  * LN_MAXDOUBLE	- the natural log of the largest double  -- log(MAXDOUBLE)
78  * LN_MINDOUBLE	- the natural log of the smallest double -- log(MINDOUBLE)
79  * LN_MAXFLOAT	- the natural log of the largest float
80  * LN_MINFLOAT	- the natural log of the smallest float
81  */
82 #if u3b || u3b5 || sun || bsdmachine
83 #define MAXDOUBLE	1.797693134862315708e+308
84 #define MAXFLOAT	((float)3.40282346638528860e+38)
85 #define MINDOUBLE	4.94065645841246544e-324
86 #define MINFLOAT	((float)1.40129846432481707e-45)
87 #define	_IEEE		1
88 #define _DEXPLEN	11
89 #define _HIDDENBIT	1
90 #define DMINEXP	(-(DMAXEXP + DSIGNIF - _HIDDENBIT - 3))
91 #define FMINEXP	(-(FMAXEXP + FSIGNIF - _HIDDENBIT - 3))
92 #define LN_MAXFLOAT	8.8722839052068e+01
93 #define LN_MINFLOAT	-1.03278929903432e+02
94 #endif
95 #if pdp11 || vax
96 #define MAXDOUBLE	1.701411834604692293e+38
97 #define MAXFLOAT	((float)1.701411733192644299e+38)
98 /* The following is kludged because the PDP-11 compilers botch the simple form.
99    The kludge causes the constant to be computed at run-time on the PDP-11,
100    even though it is still "folded" at compile-time on the VAX. */
101 #define MINDOUBLE	(0.01 * 2.938735877055718770e-37)
102 #define MINFLOAT	((float)MINDOUBLE)
103 #define _IEEE		0
104 #define _DEXPLEN	8
105 #define _HIDDENBIT	1
106 #define DMINEXP	(-DMAXEXP)
107 #define FMINEXP	(-FMAXEXP)
108 #endif
109 #if gcos
110 #define MAXDOUBLE	1.7014118346046923171e+38
111 #define MAXFLOAT	((float)1.7014118219281863150e+38)
112 #define MINDOUBLE	2.9387358770557187699e-39
113 #define MINFLOAT	((float)MINDOUBLE)
114 #define _IEEE		0
115 #define _DEXPLEN	8
116 #define _HIDDENBIT	0
117 #define DMINEXP	(-(DMAXEXP + 1))
118 #define FMINEXP	(-(FMAXEXP + 1))
119 #endif
120 #if u370
121 #define _LENBASE	4
122 #else
123 #define _LENBASE	1
124 #endif
125 #define _EXPBASE	(1 << _LENBASE)
126 #define _FEXPLEN	8
127 #define DSIGNIF	(BITS(double) - _DEXPLEN + _HIDDENBIT - 1)
128 #define FSIGNIF	(BITS(float)  - _FEXPLEN + _HIDDENBIT - 1)
129 #define DMAXPOWTWO	((double)(1L << (BITS(int) - 2)) * \
130 				(1L << (DSIGNIF - BITS(int) + 1)))
131 #define FMAXPOWTWO	((float)(1L << FSIGNIF - 1))
132 #define DMAXEXP	((1 << _DEXPLEN - 1) - 1 + _IEEE)
133 #define FMAXEXP	((1 << _FEXPLEN - 1) - 1 + _IEEE)
134 #define LN_MAXDOUBLE	(M_LN2 * DMAXEXP)
135 #define LN_MINDOUBLE	(M_LN2 * (DMINEXP - 1))
136 
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 
148 #endif /*!_values_h*/
149