xref: /illumos-gate/usr/src/head/float.h (revision 581cede61ac9c14d8d4ea452562a567189eead78)
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 /*	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 _FLOAT_H
32 #define	_FLOAT_H
33 
34 #pragma ident	"%Z%%M%	%I%	%E% SMI"
35 
36 #include <sys/feature_tests.h>
37 
38 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 #if defined(__sparc)
43 
44 #if defined(__STDC__)
45 extern int __flt_rounds(void);
46 #else	/* defined(__STDC__) */
47 extern int __flt_rounds();
48 #endif	/* defined(__STDC__) */
49 #define	FLT_ROUNDS	__flt_rounds()
50 
51 #else /* defined(__sparc) */
52 
53 #if defined(__STDC__)
54 extern int __fltrounds(void);
55 #else	/* defined (__STDC__) */
56 extern int __fltrounds();
57 #endif	/* defined(__STDC__) */
58 #if defined(__amd64)
59 #define	FLT_ROUNDS	__fltrounds()
60 #else	/* defined(__amd64) */
61 extern int __flt_rounds;
62 #define	FLT_ROUNDS	__flt_rounds
63 #endif	/* defined(__amd64) */
64 #endif /* defined(__sparc) */
65 
66 /* Introduced in ISO/IEC 9899:1999 standard */
67 #if defined(__EXTENSIONS__) || defined(_STDC_C99) || \
68 	(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))
69 #if defined(__FLT_EVAL_METHOD__)
70 #define	FLT_EVAL_METHOD __FLT_EVAL_METHOD__
71 #else
72 #define	FLT_EVAL_METHOD	-1
73 #endif /* defined(__FLT_EVAL_METHOD__) */
74 #endif /* defined(__EXTENSIONS__) || defined(_STDC_C99)... */
75 
76 #define	FLT_RADIX	2
77 #define	FLT_MANT_DIG	24
78 #define	FLT_EPSILON	1.1920928955078125000000E-07F
79 #define	FLT_DIG		6
80 #define	FLT_MIN_EXP	(-125)
81 #define	FLT_MIN		1.1754943508222875079688E-38F
82 #define	FLT_MIN_10_EXP	(-37)
83 #define	FLT_MAX_EXP	(+128)
84 #define	FLT_MAX		3.4028234663852885981170E+38F
85 #define	FLT_MAX_10_EXP	(+38)
86 
87 #define	DBL_MANT_DIG	53
88 #define	DBL_EPSILON	2.2204460492503130808473E-16
89 #define	DBL_DIG		15
90 #define	DBL_MIN_EXP	(-1021)
91 #define	DBL_MIN		2.2250738585072013830903E-308
92 #define	DBL_MIN_10_EXP	(-307)
93 #define	DBL_MAX_EXP	(+1024)
94 #define	DBL_MAX		1.7976931348623157081452E+308
95 #define	DBL_MAX_10_EXP	(+308)
96 
97 /* Introduced in ISO/IEC 9899:1999 standard */
98 #if defined(__EXTENSIONS__) || defined(_STDC_C99) || \
99 	(!defined(_STRICT_STDC) && !defined(__XOPEN_OR_POSIX))
100 #if defined(__sparc)
101 #define	DECIMAL_DIG	36
102 #elif defined(__i386) || defined(__amd64)
103 #define	DECIMAL_DIG	21
104 #endif
105 #endif /* defined(__EXTENSIONS__) || defined(_STDC_C99)... */
106 
107 
108 #if defined(__i386) || defined(__amd64)
109 
110 /* Follows IEEE standards for 80-bit floating point */
111 #define	LDBL_MANT_DIG	64
112 #define	LDBL_EPSILON	1.0842021724855044340075E-19L
113 #define	LDBL_DIG	18
114 #define	LDBL_MIN_EXP	(-16381)
115 #define	LDBL_MIN	3.3621031431120935062627E-4932L
116 #define	LDBL_MIN_10_EXP	(-4931)
117 #define	LDBL_MAX_EXP	(+16384)
118 #define	LDBL_MAX	1.1897314953572317650213E+4932L
119 #define	LDBL_MAX_10_EXP	(+4932)
120 
121 #elif defined(__sparc)
122 
123 /* Follows IEEE standards for 128-bit floating point */
124 #define	LDBL_MANT_DIG	113
125 #define	LDBL_EPSILON	1.925929944387235853055977942584927319E-34L
126 #define	LDBL_DIG	33
127 #define	LDBL_MIN_EXP	(-16381)
128 #define	LDBL_MIN	3.362103143112093506262677817321752603E-4932L
129 #define	LDBL_MIN_10_EXP	(-4931)
130 #define	LDBL_MAX_EXP	(+16384)
131 #define	LDBL_MAX	1.189731495357231765085759326628007016E+4932L
132 #define	LDBL_MAX_10_EXP	(+4932)
133 
134 #else
135 
136 #error "Unknown architecture!"
137 
138 #endif
139 
140 
141 #ifdef	__cplusplus
142 }
143 #endif
144 
145 #endif	/* _FLOAT_H */
146