xref: /titanic_41/usr/src/lib/libbc/inc/include/values.h (revision 74e20cfe817b82802b16fac8690dadcda76f54f5)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifndef _values_h
33 #define _values_h
34 
35 /* These values work with any binary representation of integers
36  * where the high-order bit contains the sign. */
37 
38 /* a number used normally for size of a shift */
39 #if gcos
40 #define BITSPERBYTE	9
41 #else
42 #define BITSPERBYTE	8
43 #endif
44 #define BITS(type)	(BITSPERBYTE * (int)sizeof(type))
45 
46 /* short, regular and long ints with only the high-order bit turned on */
47 #define HIBITS	((short)(1 << BITS(short) - 1))
48 #define HIBITI	(1U << BITS(int) - 1)
49 #define HIBITL	(1UL << BITS(long) - 1)
50 
51 /* largest short, regular and long int */
52 #define MAXSHORT	((short)~HIBITS)
53 #define MAXINT	((int)~HIBITI)
54 #define MAXLONG	((long)~HIBITL)
55 
56 /* various values that describe the binary floating-point representation
57  * _EXPBASE	- the exponent base
58  * DMAXEXP 	- the maximum exponent of a double (as returned by frexp())
59  * FMAXEXP 	- the maximum exponent of a float  (as returned by frexp())
60  * DMINEXP 	- the minimum exponent of a double (as returned by frexp())
61  * FMINEXP 	- the minimum exponent of a float  (as returned by frexp())
62  * MAXDOUBLE	- the largest double
63 			((_EXPBASE ** DMAXEXP) * (1 - (_EXPBASE ** -DSIGNIF)))
64  * MAXFLOAT	- the largest float
65 			((_EXPBASE ** FMAXEXP) * (1 - (_EXPBASE ** -FSIGNIF)))
66  * MINDOUBLE	- the smallest double (_EXPBASE ** (DMINEXP - 1))
67  * MINFLOAT	- the smallest float (_EXPBASE ** (FMINEXP - 1))
68  * DSIGNIF	- the number of significant bits in a double
69  * FSIGNIF	- the number of significant bits in a float
70  * DMAXPOWTWO	- the largest power of two exactly representable as a double
71  * FMAXPOWTWO	- the largest power of two exactly representable as a float
72  * _IEEE	- 1 if IEEE standard representation is used
73  * _DEXPLEN	- the number of bits for the exponent of a double
74  * _FEXPLEN	- the number of bits for the exponent of a float
75  * _HIDDENBIT	- 1 if high-significance bit of mantissa is implicit
76  * LN_MAXDOUBLE	- the natural log of the largest double  -- log(MAXDOUBLE)
77  * LN_MINDOUBLE	- the natural log of the smallest double -- log(MINDOUBLE)
78  * LN_MAXFLOAT	- the natural log of the largest float
79  * LN_MINFLOAT	- the natural log of the smallest float
80  */
81 #if u3b || u3b5 || sun
82 #define MAXDOUBLE	1.797693134862315708e+308
83 #define MAXFLOAT	((float)3.40282346638528860e+38)
84 #define MINDOUBLE	4.94065645841246544e-324
85 #define MINFLOAT	((float)1.40129846432481707e-45)
86 #define	_IEEE		1
87 #define _DEXPLEN	11
88 #define _HIDDENBIT	1
89 #define DMINEXP	(-(DMAXEXP + DSIGNIF - _HIDDENBIT - 3))
90 #define FMINEXP	(-(FMAXEXP + FSIGNIF - _HIDDENBIT - 3))
91 #define LN_MAXFLOAT	8.8722839052068e+01
92 #define LN_MINFLOAT	-1.03278929903432e+02
93 #endif
94 #if pdp11 || vax
95 #define MAXDOUBLE	1.701411834604692293e+38
96 #define MAXFLOAT	((float)1.701411733192644299e+38)
97 /* The following is kludged because the PDP-11 compilers botch the simple form.
98    The kludge causes the constant to be computed at run-time on the PDP-11,
99    even though it is still "folded" at compile-time on the VAX. */
100 #define MINDOUBLE	(0.01 * 2.938735877055718770e-37)
101 #define MINFLOAT	((float)MINDOUBLE)
102 #define _IEEE		0
103 #define _DEXPLEN	8
104 #define _HIDDENBIT	1
105 #define DMINEXP	(-DMAXEXP)
106 #define FMINEXP	(-FMAXEXP)
107 #endif
108 #if gcos
109 #define MAXDOUBLE	1.7014118346046923171e+38
110 #define MAXFLOAT	((float)1.7014118219281863150e+38)
111 #define MINDOUBLE	2.9387358770557187699e-39
112 #define MINFLOAT	((float)MINDOUBLE)
113 #define _IEEE		0
114 #define _DEXPLEN	8
115 #define _HIDDENBIT	0
116 #define DMINEXP	(-(DMAXEXP + 1))
117 #define FMINEXP	(-(FMAXEXP + 1))
118 #endif
119 #if u370
120 #define _LENBASE	4
121 #else
122 #define _LENBASE	1
123 #endif
124 #define _EXPBASE	(1 << _LENBASE)
125 #define _FEXPLEN	8
126 #define DSIGNIF	(BITS(double) - _DEXPLEN + _HIDDENBIT - 1)
127 #define FSIGNIF	(BITS(float)  - _FEXPLEN + _HIDDENBIT - 1)
128 #define DMAXPOWTWO	((double)(1L << BITS(long) - 2) * \
129 				(1L << DSIGNIF - BITS(long) + 1))
130 #define FMAXPOWTWO	((float)(1L << FSIGNIF - 1))
131 #define DMAXEXP	((1 << _DEXPLEN - 1) - 1 + _IEEE)
132 #define FMAXEXP	((1 << _FEXPLEN - 1) - 1 + _IEEE)
133 #define LN_MAXDOUBLE	(M_LN2 * DMAXEXP)
134 #define LN_MINDOUBLE	(M_LN2 * (DMINEXP - 1))
135 
136 #define H_PREC	(DSIGNIF % 2 ? (1L << DSIGNIF/2) * M_SQRT2 : 1L << DSIGNIF/2)
137 #define X_EPS	(1.0/H_PREC)
138 #define X_PLOSS	((double)(long)(M_PI * H_PREC))
139 #define X_TLOSS	(M_PI * DMAXPOWTWO)
140 #define M_LN2	0.69314718055994530942
141 #define M_PI	3.14159265358979323846
142 #define M_SQRT2	1.41421356237309504880
143 #define MAXBEXP	DMAXEXP /* for backward compatibility */
144 #define MINBEXP	DMINEXP /* for backward compatibility */
145 #define MAXPOWTWO	DMAXPOWTWO /* for backward compatibility */
146 
147 #endif /*!_values_h*/
148