root / lab4 / .minix-src / include / sys / float_ieee754.h @ 13
History | View | Annotate | Download (5.35 KB)
1 | 13 | up20180614 | /* $NetBSD: float_ieee754.h,v 1.11 2013/06/18 20:17:19 christos Exp $ */
|
---|---|---|---|
2 | |||
3 | /*
|
||
4 | * Copyright (c) 1992, 1993
|
||
5 | * The Regents of the University of California. All rights reserved.
|
||
6 | *
|
||
7 | * Redistribution and use in source and binary forms, with or without
|
||
8 | * modification, are permitted provided that the following conditions
|
||
9 | * are met:
|
||
10 | * 1. Redistributions of source code must retain the above copyright
|
||
11 | * notice, this list of conditions and the following disclaimer.
|
||
12 | * 2. Redistributions in binary form must reproduce the above copyright
|
||
13 | * notice, this list of conditions and the following disclaimer in the
|
||
14 | * documentation and/or other materials provided with the distribution.
|
||
15 | * 3. Neither the name of the University nor the names of its contributors
|
||
16 | * may be used to endorse or promote products derived from this software
|
||
17 | * without specific prior written permission.
|
||
18 | *
|
||
19 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||
20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||
21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||
22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||
23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||
24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||
25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||
26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||
27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||
28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||
29 | * SUCH DAMAGE.
|
||
30 | *
|
||
31 | * @(#)float.h 8.1 (Berkeley) 6/10/93
|
||
32 | */
|
||
33 | |||
34 | /*
|
||
35 | * NOTICE: This is not a standalone file. To use it, #include it in
|
||
36 | * your port's float.h header.
|
||
37 | */
|
||
38 | |||
39 | #ifndef _SYS_FLOAT_IEEE754_H_
|
||
40 | #define _SYS_FLOAT_IEEE754_H_
|
||
41 | |||
42 | #include <sys/cdefs.h> |
||
43 | #include <sys/featuretest.h> |
||
44 | |||
45 | /*
|
||
46 | * feature macro to test for IEEE754
|
||
47 | */
|
||
48 | #define _FLOAT_IEEE754 1 |
||
49 | |||
50 | #if !defined(__ASSEMBLER__) && !defined(FLT_ROUNDS)
|
||
51 | __BEGIN_DECLS |
||
52 | extern int __flt_rounds(void); |
||
53 | __END_DECLS |
||
54 | #define FLT_ROUNDS __flt_rounds()
|
||
55 | #endif
|
||
56 | |||
57 | #if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \
|
||
58 | !defined(_XOPEN_SOURCE) || \ |
||
59 | ((__STDC_VERSION__ - 0) >= 199901L) || \ |
||
60 | ((_POSIX_C_SOURCE - 0) >= 200112L) || \ |
||
61 | ((_XOPEN_SOURCE - 0) >= 600) || \ |
||
62 | defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE) |
||
63 | #ifndef FLT_EVAL_METHOD
|
||
64 | #if __GNUC_PREREQ__(3, 3) |
||
65 | #define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
|
||
66 | #endif /* GCC >= 3.3 */ |
||
67 | #endif /* defined(FLT_EVAL_METHOD) */ |
||
68 | #endif /* !defined(_ANSI_SOURCE) && ... */ |
||
69 | |||
70 | #if __GNUC_PREREQ__(3, 3) |
||
71 | /*
|
||
72 | * GCC 3,3 and later provide builtins for the FLT, DBL, and LDBL constants.
|
||
73 | */
|
||
74 | #define FLT_RADIX __FLT_RADIX__
|
||
75 | |||
76 | #define FLT_MANT_DIG __FLT_MANT_DIG__
|
||
77 | #define FLT_EPSILON __FLT_EPSILON__
|
||
78 | #define FLT_DIG __FLT_DIG__
|
||
79 | #define FLT_MIN_EXP __FLT_MIN_EXP__
|
||
80 | #define FLT_MIN __FLT_MIN__
|
||
81 | #define FLT_MIN_10_EXP __FLT_MIN_10_EXP__
|
||
82 | #define FLT_MAX_EXP __FLT_MAX_EXP__
|
||
83 | #define FLT_MAX __FLT_MAX__
|
||
84 | #define FLT_MAX_10_EXP __FLT_MAX_10_EXP__
|
||
85 | |||
86 | #define DBL_MANT_DIG __DBL_MANT_DIG__
|
||
87 | #define DBL_EPSILON __DBL_EPSILON__
|
||
88 | #define DBL_DIG __DBL_DIG__
|
||
89 | #define DBL_MIN_EXP __DBL_MIN_EXP__
|
||
90 | #define DBL_MIN __DBL_MIN__
|
||
91 | #define DBL_MIN_10_EXP __DBL_MIN_10_EXP__
|
||
92 | #define DBL_MAX_EXP __DBL_MAX_EXP__
|
||
93 | #define DBL_MAX __DBL_MAX__
|
||
94 | #define DBL_MAX_10_EXP __DBL_MAX_10_EXP__
|
||
95 | #else /* GCC < 3.3 */ |
||
96 | #define FLT_RADIX 2 /* b */ |
||
97 | |||
98 | #define FLT_MANT_DIG 24 /* p */ |
||
99 | #define FLT_DIG 6 /* floor((p-1)*log10(b))+(b == 10) */ |
||
100 | #define FLT_MIN_EXP (-125) /* emin */ |
||
101 | #define FLT_MIN_10_EXP (-37) /* ceil(log10(b**(emin-1))) */ |
||
102 | #define FLT_MAX_EXP 128 /* emax */ |
||
103 | #define FLT_MAX_10_EXP 38 /* floor(log10((1-b**(-p))*b**emax)) */ |
||
104 | #if __STDC_VERSION__ >= 199901L |
||
105 | #define FLT_EPSILON 0x1.0p-23F |
||
106 | #define FLT_MIN 0x1.0p-126F |
||
107 | #define FLT_MAX 0x1.fffffep+127F |
||
108 | #else
|
||
109 | #define FLT_EPSILON 1.19209290E-7F /* b**(1-p) */ |
||
110 | #define FLT_MIN 1.17549435E-38F /* b**(emin-1) */ |
||
111 | #define FLT_MAX 3.40282347E+38F /* (1-b**(-p))*b**emax */ |
||
112 | #endif
|
||
113 | |||
114 | #define DBL_MANT_DIG 53 |
||
115 | #define DBL_DIG 15 |
||
116 | #define DBL_MIN_EXP (-1021) |
||
117 | #define DBL_MIN_10_EXP (-307) |
||
118 | #define DBL_MAX_EXP 1024 |
||
119 | #define DBL_MAX_10_EXP 308 |
||
120 | |||
121 | #if __STDC_VERSION__ >= 199901L |
||
122 | #define DBL_EPSILON 0x1.0p-52 |
||
123 | #define DBL_MIN 0x1.0p-1022 |
||
124 | #define DBL_MAX 0x1.fffffffffffffp+1023 |
||
125 | #else
|
||
126 | #define DBL_EPSILON 2.2204460492503131E-16 |
||
127 | #define DBL_MIN 2.2250738585072014E-308 |
||
128 | #define DBL_MAX 1.7976931348623157E+308 |
||
129 | #endif
|
||
130 | #endif /* GCC < 3.3 */ |
||
131 | /*
|
||
132 | * If no extended-precision type is defined by the machine-dependent
|
||
133 | * header including this, default to `long double' being double-precision.
|
||
134 | */
|
||
135 | #ifndef LDBL_MANT_DIG
|
||
136 | #define LDBL_MANT_DIG DBL_MANT_DIG
|
||
137 | #define LDBL_EPSILON DBL_EPSILON
|
||
138 | #define LDBL_DIG DBL_DIG
|
||
139 | #define LDBL_MIN_EXP DBL_MIN_EXP
|
||
140 | #define LDBL_MIN DBL_MIN
|
||
141 | #define LDBL_MIN_10_EXP DBL_MIN_10_EXP
|
||
142 | #define LDBL_MAX_EXP DBL_MAX_EXP
|
||
143 | #define LDBL_MAX DBL_MAX
|
||
144 | #define LDBL_MAX_10_EXP DBL_MAX_10_EXP
|
||
145 | #if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \
|
||
146 | !defined(_XOPEN_SOURCE) || \ |
||
147 | ((__STDC_VERSION__ - 0) >= 199901L) || \ |
||
148 | ((_POSIX_C_SOURCE - 0) >= 200112L) || \ |
||
149 | ((_XOPEN_SOURCE - 0) >= 600) || \ |
||
150 | defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE) |
||
151 | #if __GNUC_PREREQ__(3, 3) |
||
152 | #define DECIMAL_DIG __DECIMAL_DIG__
|
||
153 | #else
|
||
154 | #define DECIMAL_DIG 17 /* ceil((1+p*log10(b))-(b==10) */ |
||
155 | #endif
|
||
156 | #endif /* !defined(_ANSI_SOURCE) && ... */ |
||
157 | #endif /* LDBL_MANT_DIG */ |
||
158 | |||
159 | #endif /* _SYS_FLOAT_IEEE754_H_ */ |