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 /* Copyright (c) 1988 AT&T */
23 /* All Rights Reserved */
24
25
26 /*
27 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
28 * Use is subject to license terms.
29 */
30
31 #ifndef _VALUES_H
32 #define _VALUES_H
33
34 #pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.33 */
35
36 #include <sys/isa_defs.h>
37
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41
42 /*
43 * These values work with any binary representation of integers
44 * where the high-order bit contains the sign.
45 */
46
47 /* a number used normally for size of a shift */
48 #define BITSPERBYTE 8
49
50 #define BITS(type) (BITSPERBYTE * (long)sizeof (type))
51
52 /* short, regular and long ints with only the high-order bit turned on */
53 #define HIBITS ((short)(1 << (BITS(short) - 1)))
54
55 #if defined(__STDC__)
56
57 #define HIBITI (1U << (BITS(int) - 1))
58 #define HIBITL (1UL << (BITS(long) - 1))
59
60 #else
61
62 #define HIBITI ((unsigned)1 << (BITS(int) - 1))
63 #define HIBITL (1L << (BITS(long) - 1))
64
65 #endif
66
67 /* largest short, regular and long int */
68 #define MAXSHORT ((short)~HIBITS)
69 #define MAXINT ((int)(~HIBITI))
70 #define MAXLONG ((long)(~HIBITL))
71
72 /*
73 * various values that describe the binary floating-point representation
74 * _EXPBASE - the exponent base
75 * DMAXEXP - the maximum exponent of a double (as returned by frexp())
76 * FMAXEXP - the maximum exponent of a float (as returned by frexp())
77 * DMINEXP - the minimum exponent of a double (as returned by frexp())
78 * FMINEXP - the minimum exponent of a float (as returned by frexp())
79 * MAXDOUBLE - the largest double
80 * ((_EXPBASE ** DMAXEXP) * (1 - (_EXPBASE ** -DSIGNIF)))
81 * MAXFLOAT - the largest float
82 * ((_EXPBASE ** FMAXEXP) * (1 - (_EXPBASE ** -FSIGNIF)))
83 * MINDOUBLE - the smallest double (_EXPBASE ** (DMINEXP - 1))
84 * MINFLOAT - the smallest float (_EXPBASE ** (FMINEXP - 1))
85 * DSIGNIF - the number of significant bits in a double
86 * FSIGNIF - the number of significant bits in a float
|
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 /* Copyright (c) 1988 AT&T */
23 /* All Rights Reserved */
24
25
26 /*
27 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
28 *
29 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
30 * Use is subject to license terms.
31 */
32
33 #ifndef _VALUES_H
34 #define _VALUES_H
35
36 #include <sys/isa_defs.h>
37
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41
42 /*
43 * These values work with any binary representation of integers
44 * where the high-order bit contains the sign.
45 */
46
47 /* a number used normally for size of a shift */
48 #define BITSPERBYTE 8
49
50 #define BITS(type) (BITSPERBYTE * (long)sizeof (type))
51
52 /* short, regular and long ints with only the high-order bit turned on */
53 #define HIBITS ((short)(1 << (BITS(short) - 1)))
54
55 #define HIBITI (1U << (BITS(int) - 1))
56 #define HIBITL (1UL << (BITS(long) - 1))
57
58 /* largest short, regular and long int */
59 #define MAXSHORT ((short)~HIBITS)
60 #define MAXINT ((int)(~HIBITI))
61 #define MAXLONG ((long)(~HIBITL))
62
63 /*
64 * various values that describe the binary floating-point representation
65 * _EXPBASE - the exponent base
66 * DMAXEXP - the maximum exponent of a double (as returned by frexp())
67 * FMAXEXP - the maximum exponent of a float (as returned by frexp())
68 * DMINEXP - the minimum exponent of a double (as returned by frexp())
69 * FMINEXP - the minimum exponent of a float (as returned by frexp())
70 * MAXDOUBLE - the largest double
71 * ((_EXPBASE ** DMAXEXP) * (1 - (_EXPBASE ** -DSIGNIF)))
72 * MAXFLOAT - the largest float
73 * ((_EXPBASE ** FMAXEXP) * (1 - (_EXPBASE ** -FSIGNIF)))
74 * MINDOUBLE - the smallest double (_EXPBASE ** (DMINEXP - 1))
75 * MINFLOAT - the smallest float (_EXPBASE ** (FMINEXP - 1))
76 * DSIGNIF - the number of significant bits in a double
77 * FSIGNIF - the number of significant bits in a float
|