]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Copyright Christopher Kormanyos 2014. | |
3 | // Copyright John Maddock 2014. | |
4 | // Copyright Paul Bristow 2014. | |
5 | // Distributed under the Boost Software License, | |
6 | // Version 1.0. (See accompanying file LICENSE_1_0.txt | |
7 | // or copy at http://www.boost.org/LICENSE_1_0.txt) | |
8 | // | |
9 | ||
10 | // Implement the types for floating-point typedefs having specified widths. | |
11 | ||
12 | #ifndef _BOOST_CSTDFLOAT_TYPES_2014_01_09_HPP_ | |
13 | #define _BOOST_CSTDFLOAT_TYPES_2014_01_09_HPP_ | |
14 | ||
15 | #include <float.h> | |
16 | #include <limits> | |
17 | #include <boost/static_assert.hpp> | |
18 | #include <boost/math/tools/config.hpp> | |
19 | ||
20 | // This is the beginning of the preamble. | |
21 | ||
22 | // In this preamble, the preprocessor is used to query certain | |
23 | // preprocessor definitions from <float.h>. Based on the results | |
24 | // of these queries, an attempt is made to automatically detect | |
25 | // the presence of built-in floating-point types having specified | |
26 | // widths. These are *thought* to be conformant with IEEE-754, | |
27 | // whereby an unequivocal test based on std::numeric_limits<> | |
28 | // follows below. | |
29 | ||
30 | // In addition, various macros that are used for initializing | |
31 | // floating-point literal values having specified widths and | |
32 | // some basic min/max values are defined. | |
33 | ||
34 | // First, we will pre-load certain preprocessor definitions | |
35 | // with a dummy value. | |
36 | ||
37 | #define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 0 | |
38 | ||
39 | #define BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE 0 | |
40 | #define BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE 0 | |
41 | #define BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE 0 | |
42 | #define BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE 0 | |
43 | #define BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE 0 | |
44 | ||
45 | // Ensure that the compiler has a radix-2 floating-point representation. | |
46 | #if (!defined(FLT_RADIX) || ((defined(FLT_RADIX) && (FLT_RADIX != 2)))) | |
47 | #error The compiler does not support any radix-2 floating-point types required for <boost/cstdfloat.hpp>. | |
48 | #endif | |
49 | ||
50 | // Check if built-in float is equivalent to float16_t, float32_t, float64_t, float80_t, or float128_t. | |
51 | #if(defined(FLT_MANT_DIG) && defined(FLT_MAX_EXP)) | |
52 | #if ((FLT_MANT_DIG == 11) && (FLT_MAX_EXP == 16) && (BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE == 0)) | |
53 | #define BOOST_CSTDFLOAT_FLOAT16_NATIVE_TYPE float | |
54 | #undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH | |
55 | #define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 16 | |
56 | #undef BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE | |
57 | #define BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE 1 | |
58 | #define BOOST_FLOAT16_C(x) (x ## F) | |
59 | #define BOOST_CSTDFLOAT_FLOAT_16_MIN FLT_MIN | |
60 | #define BOOST_CSTDFLOAT_FLOAT_16_MAX FLT_MAX | |
61 | #elif((FLT_MANT_DIG == 24) && (FLT_MAX_EXP == 128) && (BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE == 0)) | |
62 | #define BOOST_CSTDFLOAT_FLOAT32_NATIVE_TYPE float | |
63 | #undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH | |
64 | #define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 32 | |
65 | #undef BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE | |
66 | #define BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE 1 | |
67 | #define BOOST_FLOAT32_C(x) (x ## F) | |
68 | #define BOOST_CSTDFLOAT_FLOAT_32_MIN FLT_MIN | |
69 | #define BOOST_CSTDFLOAT_FLOAT_32_MAX FLT_MAX | |
70 | #elif((FLT_MANT_DIG == 53) && (FLT_MAX_EXP == 1024) && (BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE == 0)) | |
71 | #define BOOST_CSTDFLOAT_FLOAT64_NATIVE_TYPE float | |
72 | #undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH | |
73 | #define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 64 | |
74 | #undef BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE | |
75 | #define BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE 1 | |
76 | #define BOOST_FLOAT64_C(x) (x ## F) | |
77 | #define BOOST_CSTDFLOAT_FLOAT_64_MIN FLT_MIN | |
78 | #define BOOST_CSTDFLOAT_FLOAT_64_MAX FLT_MAX | |
79 | #elif((FLT_MANT_DIG == 64) && (FLT_MAX_EXP == 16384) && (BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE == 0)) | |
80 | #define BOOST_CSTDFLOAT_FLOAT80_NATIVE_TYPE float | |
81 | #undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH | |
82 | #define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 80 | |
83 | #undef BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE | |
84 | #define BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE 1 | |
85 | #define BOOST_FLOAT80_C(x) (x ## F) | |
86 | #define BOOST_CSTDFLOAT_FLOAT_80_MIN FLT_MIN | |
87 | #define BOOST_CSTDFLOAT_FLOAT_80_MAX FLT_MAX | |
88 | #elif((FLT_MANT_DIG == 113) && (FLT_MAX_EXP == 16384) && (BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE == 0)) | |
89 | #define BOOST_CSTDFLOAT_FLOAT128_NATIVE_TYPE float | |
90 | #undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH | |
91 | #define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 128 | |
92 | #undef BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE | |
93 | #define BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE 1 | |
94 | #define BOOST_FLOAT128_C(x) (x ## F) | |
95 | #define BOOST_CSTDFLOAT_FLOAT_128_MIN FLT_MIN | |
96 | #define BOOST_CSTDFLOAT_FLOAT_128_MAX FLT_MAX | |
97 | #endif | |
98 | #endif | |
99 | ||
100 | // Check if built-in double is equivalent to float16_t, float32_t, float64_t, float80_t, or float128_t. | |
101 | #if(defined(DBL_MANT_DIG) && defined(DBL_MAX_EXP)) | |
102 | #if ((DBL_MANT_DIG == 11) && (DBL_MAX_EXP == 16) && (BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE == 0)) | |
103 | #define BOOST_CSTDFLOAT_FLOAT16_NATIVE_TYPE double | |
104 | #undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH | |
105 | #define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 16 | |
106 | #undef BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE | |
107 | #define BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE 1 | |
108 | #define BOOST_FLOAT16_C(x) (x) | |
109 | #define BOOST_CSTDFLOAT_FLOAT_16_MIN DBL_MIN | |
110 | #define BOOST_CSTDFLOAT_FLOAT_16_MAX DBL_MAX | |
111 | #elif((DBL_MANT_DIG == 24) && (DBL_MAX_EXP == 128) && (BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE == 0)) | |
112 | #define BOOST_CSTDFLOAT_FLOAT32_NATIVE_TYPE double | |
113 | #undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH | |
114 | #define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 32 | |
115 | #undef BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE | |
116 | #define BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE 1 | |
117 | #define BOOST_FLOAT32_C(x) (x) | |
118 | #define BOOST_CSTDFLOAT_FLOAT_32_MIN DBL_MIN | |
119 | #define BOOST_CSTDFLOAT_FLOAT_32_MAX DBL_MAX | |
120 | #elif((DBL_MANT_DIG == 53) && (DBL_MAX_EXP == 1024) && (BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE == 0)) | |
121 | #define BOOST_CSTDFLOAT_FLOAT64_NATIVE_TYPE double | |
122 | #undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH | |
123 | #define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 64 | |
124 | #undef BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE | |
125 | #define BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE 1 | |
126 | #define BOOST_FLOAT64_C(x) (x) | |
127 | #define BOOST_CSTDFLOAT_FLOAT_64_MIN DBL_MIN | |
128 | #define BOOST_CSTDFLOAT_FLOAT_64_MAX DBL_MAX | |
129 | #elif((DBL_MANT_DIG == 64) && (DBL_MAX_EXP == 16384) && (BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE == 0)) | |
130 | #define BOOST_CSTDFLOAT_FLOAT80_NATIVE_TYPE double | |
131 | #undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH | |
132 | #define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 80 | |
133 | #undef BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE | |
134 | #define BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE 1 | |
135 | #define BOOST_FLOAT80_C(x) (x) | |
136 | #define BOOST_CSTDFLOAT_FLOAT_80_MIN DBL_MIN | |
137 | #define BOOST_CSTDFLOAT_FLOAT_80_MAX DBL_MAX | |
138 | #elif((DBL_MANT_DIG == 113) && (DBL_MAX_EXP == 16384) && (BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE == 0)) | |
139 | #define BOOST_CSTDFLOAT_FLOAT128_NATIVE_TYPE double | |
140 | #undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH | |
141 | #define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 128 | |
142 | #undef BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE | |
143 | #define BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE 1 | |
144 | #define BOOST_FLOAT128_C(x) (x) | |
145 | #define BOOST_CSTDFLOAT_FLOAT_128_MIN DBL_MIN | |
146 | #define BOOST_CSTDFLOAT_FLOAT_128_MAX DBL_MAX | |
147 | #endif | |
148 | #endif | |
149 | ||
150 | // Disable check long double capability even if supported by compiler since some math runtime | |
151 | // implementations are broken for long double. | |
152 | #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS | |
153 | // Check if built-in long double is equivalent to float16_t, float32_t, float64_t, float80_t, or float128_t. | |
154 | #if(defined(LDBL_MANT_DIG) && defined(LDBL_MAX_EXP)) | |
155 | #if ((LDBL_MANT_DIG == 11) && (LDBL_MAX_EXP == 16) && (BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE == 0)) | |
156 | #define BOOST_CSTDFLOAT_FLOAT16_NATIVE_TYPE long double | |
157 | #undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH | |
158 | #define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 16 | |
159 | #undef BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE | |
160 | #define BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE 1 | |
161 | #define BOOST_FLOAT16_C(x) (x ## L) | |
162 | #define BOOST_CSTDFLOAT_FLOAT_16_MIN LDBL_MIN | |
163 | #define BOOST_CSTDFLOAT_FLOAT_16_MAX LDBL_MAX | |
164 | #elif((LDBL_MANT_DIG == 24) && (LDBL_MAX_EXP == 128) && (BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE == 0)) | |
165 | #define BOOST_CSTDFLOAT_FLOAT32_NATIVE_TYPE long double | |
166 | #undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH | |
167 | #define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 32 | |
168 | #undef BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE | |
169 | #define BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE 1 | |
170 | #define BOOST_FLOAT32_C(x) (x ## L) | |
171 | #define BOOST_CSTDFLOAT_FLOAT_32_MIN LDBL_MIN | |
172 | #define BOOST_CSTDFLOAT_FLOAT_32_MAX LDBL_MAX | |
173 | #elif((LDBL_MANT_DIG == 53) && (LDBL_MAX_EXP == 1024) && (BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE == 0)) | |
174 | #define BOOST_CSTDFLOAT_FLOAT64_NATIVE_TYPE long double | |
175 | #undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH | |
176 | #define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 64 | |
177 | #undef BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE | |
178 | #define BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE 1 | |
179 | #define BOOST_FLOAT64_C(x) (x ## L) | |
180 | #define BOOST_CSTDFLOAT_FLOAT_64_MIN LDBL_MIN | |
181 | #define BOOST_CSTDFLOAT_FLOAT_64_MAX LDBL_MAX | |
182 | #elif((LDBL_MANT_DIG == 64) && (LDBL_MAX_EXP == 16384) && (BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE == 0)) | |
183 | #define BOOST_CSTDFLOAT_FLOAT80_NATIVE_TYPE long double | |
184 | #undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH | |
185 | #define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 80 | |
186 | #undef BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE | |
187 | #define BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE 1 | |
188 | #define BOOST_FLOAT80_C(x) (x ## L) | |
189 | #define BOOST_CSTDFLOAT_FLOAT_80_MIN LDBL_MIN | |
190 | #define BOOST_CSTDFLOAT_FLOAT_80_MAX LDBL_MAX | |
191 | #elif((LDBL_MANT_DIG == 113) && (LDBL_MAX_EXP == 16384) && (BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE == 0)) | |
192 | #define BOOST_CSTDFLOAT_FLOAT128_NATIVE_TYPE long double | |
193 | #undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH | |
194 | #define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 128 | |
195 | #undef BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE | |
196 | #define BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE 1 | |
197 | #define BOOST_FLOAT128_C(x) (x ## L) | |
198 | #define BOOST_CSTDFLOAT_FLOAT_128_MIN LDBL_MIN | |
199 | #define BOOST_CSTDFLOAT_FLOAT_128_MAX LDBL_MAX | |
200 | #endif | |
201 | #endif | |
202 | #endif | |
203 | ||
204 | // Check if quadruple-precision is supported. Here, we are checking | |
205 | // for the presence of __float128 from GCC's quadmath.h or _Quad | |
206 | // from ICC's /Qlong-double flag). To query these, we use the | |
207 | // BOOST_MATH_USE_FLOAT128 pre-processor definition from | |
208 | // <boost/math/tools/config.hpp>. | |
209 | ||
210 | #if (BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE == 0) && defined(BOOST_MATH_USE_FLOAT128) && !defined(BOOST_CSTDFLOAT_NO_LIBQUADMATH_SUPPORT) | |
211 | ||
212 | // Specify the underlying name of the internal 128-bit floating-point type definition. | |
213 | namespace boost { namespace math { namespace cstdfloat { namespace detail { | |
214 | #if defined(__GNUC__) | |
215 | typedef __float128 float_internal128_t; | |
216 | #elif defined(BOOST_INTEL) | |
217 | typedef _Quad float_internal128_t; | |
218 | #else | |
219 | #error "Sorry, the compiler is neither GCC, nor Intel, I don't know how to configure <boost/cstdfloat.hpp>." | |
220 | #endif | |
221 | } } } } // boost::math::cstdfloat::detail | |
222 | ||
223 | #define BOOST_CSTDFLOAT_FLOAT128_NATIVE_TYPE boost::math::cstdfloat::detail::float_internal128_t | |
224 | #undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH | |
225 | #define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 128 | |
226 | #undef BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE | |
227 | #define BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE 1 | |
228 | #define BOOST_FLOAT128_C(x) (x ## Q) | |
229 | #define BOOST_CSTDFLOAT_FLOAT128_MIN 3.36210314311209350626267781732175260e-4932Q | |
230 | #define BOOST_CSTDFLOAT_FLOAT128_MAX 1.18973149535723176508575932662800702e+4932Q | |
231 | #define BOOST_CSTDFLOAT_FLOAT128_EPS 1.92592994438723585305597794258492732e-0034Q | |
232 | ||
233 | #endif // Not BOOST_CSTDFLOAT_NO_LIBQUADMATH_SUPPORT (i.e., the user would like to have libquadmath support) | |
234 | ||
235 | // This is the end of the preamble, and also the end of the | |
236 | // sections providing support for the C++ standard library | |
237 | // for quadruple-precision. | |
238 | ||
239 | // Now we use the results of the queries that have been obtained | |
240 | // in the preamble (far above) for the final type definitions in | |
241 | // the namespace boost. | |
242 | ||
243 | // Make sure that the compiler has any floating-point type(s) whatsoever. | |
244 | #if ( (BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE == 0) \ | |
245 | && (BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE == 0) \ | |
246 | && (BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE == 0) \ | |
247 | && (BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE == 0) \ | |
248 | && (BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE == 0)) | |
249 | #error The compiler does not support any of the floating-point types required for <boost/cstdfloat.hpp>. | |
250 | #endif | |
251 | ||
252 | // The following section contains the various min/max macros | |
253 | // for the *leastN and *fastN types. | |
254 | ||
255 | #if(BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE == 1) | |
256 | #define BOOST_FLOAT_FAST16_MIN BOOST_CSTDFLOAT_FLOAT_16_MIN | |
257 | #define BOOST_FLOAT_LEAST16_MIN BOOST_CSTDFLOAT_FLOAT_16_MIN | |
258 | #define BOOST_FLOAT_FAST16_MAX BOOST_CSTDFLOAT_FLOAT_16_MAX | |
259 | #define BOOST_FLOAT_LEAST16_MAX BOOST_CSTDFLOAT_FLOAT_16_MAX | |
260 | #endif | |
261 | ||
262 | #if(BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE == 1) | |
263 | #define BOOST_FLOAT_FAST32_MIN BOOST_CSTDFLOAT_FLOAT_32_MIN | |
264 | #define BOOST_FLOAT_LEAST32_MIN BOOST_CSTDFLOAT_FLOAT_32_MIN | |
265 | #define BOOST_FLOAT_FAST32_MAX BOOST_CSTDFLOAT_FLOAT_32_MAX | |
266 | #define BOOST_FLOAT_LEAST32_MAX BOOST_CSTDFLOAT_FLOAT_32_MAX | |
267 | #endif | |
268 | ||
269 | #if(BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE == 1) | |
270 | #define BOOST_FLOAT_FAST64_MIN BOOST_CSTDFLOAT_FLOAT_64_MIN | |
271 | #define BOOST_FLOAT_LEAST64_MIN BOOST_CSTDFLOAT_FLOAT_64_MIN | |
272 | #define BOOST_FLOAT_FAST64_MAX BOOST_CSTDFLOAT_FLOAT_64_MAX | |
273 | #define BOOST_FLOAT_LEAST64_MAX BOOST_CSTDFLOAT_FLOAT_64_MAX | |
274 | #endif | |
275 | ||
276 | #if(BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE == 1) | |
277 | #define BOOST_FLOAT_FAST80_MIN BOOST_CSTDFLOAT_FLOAT_80_MIN | |
278 | #define BOOST_FLOAT_LEAST80_MIN BOOST_CSTDFLOAT_FLOAT_80_MIN | |
279 | #define BOOST_FLOAT_FAST80_MAX BOOST_CSTDFLOAT_FLOAT_80_MAX | |
280 | #define BOOST_FLOAT_LEAST80_MAX BOOST_CSTDFLOAT_FLOAT_80_MAX | |
281 | #endif | |
282 | ||
283 | #if(BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE == 1) | |
284 | #define BOOST_CSTDFLOAT_HAS_INTERNAL_FLOAT128_T | |
285 | ||
286 | #define BOOST_FLOAT_FAST128_MIN BOOST_CSTDFLOAT_FLOAT_128_MIN | |
287 | #define BOOST_FLOAT_LEAST128_MIN BOOST_CSTDFLOAT_FLOAT_128_MIN | |
288 | #define BOOST_FLOAT_FAST128_MAX BOOST_CSTDFLOAT_FLOAT_128_MAX | |
289 | #define BOOST_FLOAT_LEAST128_MAX BOOST_CSTDFLOAT_FLOAT_128_MAX | |
290 | #endif | |
291 | ||
292 | // The following section contains the various min/max macros | |
293 | // for the *floatmax types. | |
294 | ||
295 | #if (BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH == 16) | |
296 | #define BOOST_FLOATMAX_C(x) BOOST_FLOAT16_C(x) | |
297 | #define BOOST_FLOATMAX_MIN BOOST_CSTDFLOAT_FLOAT_16_MIN | |
298 | #define BOOST_FLOATMAX_MAX BOOST_CSTDFLOAT_FLOAT_16_MAX | |
299 | #elif(BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH == 32) | |
300 | #define BOOST_FLOATMAX_C(x) BOOST_FLOAT32_C(x) | |
301 | #define BOOST_FLOATMAX_MIN BOOST_CSTDFLOAT_FLOAT_32_MIN | |
302 | #define BOOST_FLOATMAX_MAX BOOST_CSTDFLOAT_FLOAT_32_MAX | |
303 | #elif(BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH == 64) | |
304 | #define BOOST_FLOATMAX_C(x) BOOST_FLOAT64_C(x) | |
305 | #define BOOST_FLOATMAX_MIN BOOST_CSTDFLOAT_FLOAT_64_MIN | |
306 | #define BOOST_FLOATMAX_MAX BOOST_CSTDFLOAT_FLOAT_64_MAX | |
307 | #elif(BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH == 80) | |
308 | #define BOOST_FLOATMAX_C(x) BOOST_FLOAT80_C(x) | |
309 | #define BOOST_FLOATMAX_MIN BOOST_CSTDFLOAT_FLOAT_80_MIN | |
310 | #define BOOST_FLOATMAX_MAX BOOST_CSTDFLOAT_FLOAT_80_MAX | |
311 | #elif(BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH == 128) | |
312 | #define BOOST_FLOATMAX_C(x) BOOST_FLOAT128_C(x) | |
313 | #define BOOST_FLOATMAX_MIN BOOST_CSTDFLOAT_FLOAT_128_MIN | |
314 | #define BOOST_FLOATMAX_MAX BOOST_CSTDFLOAT_FLOAT_128_MAX | |
315 | #else | |
316 | #error The maximum available floating-point width for <boost/cstdfloat.hpp> is undefined. | |
317 | #endif | |
318 | ||
319 | // And finally..., we define the floating-point typedefs having | |
320 | // specified widths. The types are defined in the namespace boost. | |
321 | ||
322 | // For simplicity, the least and fast types are type defined identically | |
323 | // as the corresponding fixed-width type. This behavior may, however, | |
324 | // be modified when being optimized for a given compiler implementation. | |
325 | ||
326 | // In addition, a clear assessment of IEEE-754 comformance is carried out | |
327 | // using compile-time assertion. | |
328 | ||
329 | namespace boost | |
330 | { | |
331 | #if(BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE == 1) | |
332 | typedef BOOST_CSTDFLOAT_FLOAT16_NATIVE_TYPE float16_t; | |
333 | typedef boost::float16_t float_fast16_t; | |
334 | typedef boost::float16_t float_least16_t; | |
335 | ||
336 | BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float16_t>::is_iec559 == true, "boost::float16_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails"); | |
337 | BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float16_t>::radix == 2, "boost::float16_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails"); | |
338 | BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float16_t>::digits == 11, "boost::float16_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails"); | |
339 | BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float16_t>::max_exponent == 16, "boost::float16_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails"); | |
340 | ||
341 | #undef BOOST_CSTDFLOAT_FLOAT_16_MIN | |
342 | #undef BOOST_CSTDFLOAT_FLOAT_16_MAX | |
343 | #endif | |
344 | ||
345 | #if(BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE == 1) | |
346 | typedef BOOST_CSTDFLOAT_FLOAT32_NATIVE_TYPE float32_t; | |
347 | typedef boost::float32_t float_fast32_t; | |
348 | typedef boost::float32_t float_least32_t; | |
349 | ||
350 | BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float32_t>::is_iec559 == true, "boost::float32_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails"); | |
351 | BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float32_t>::radix == 2, "boost::float32_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails"); | |
352 | BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float32_t>::digits == 24, "boost::float32_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails"); | |
353 | BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float32_t>::max_exponent == 128, "boost::float32_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails"); | |
354 | ||
355 | #undef BOOST_CSTDFLOAT_FLOAT_32_MIN | |
356 | #undef BOOST_CSTDFLOAT_FLOAT_32_MAX | |
357 | #endif | |
358 | ||
359 | #if (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) && defined(__SUNPRO_CC) | |
360 | #undef BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE | |
361 | #define BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE 0 | |
362 | #undef BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE | |
363 | #define BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE 0 | |
364 | #undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH | |
365 | #define BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH 64 | |
366 | #endif | |
367 | ||
368 | #if(BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE == 1) | |
369 | typedef BOOST_CSTDFLOAT_FLOAT64_NATIVE_TYPE float64_t; | |
370 | typedef boost::float64_t float_fast64_t; | |
371 | typedef boost::float64_t float_least64_t; | |
372 | ||
373 | BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float64_t>::is_iec559 == true, "boost::float64_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails"); | |
374 | BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float64_t>::radix == 2, "boost::float64_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails"); | |
375 | BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float64_t>::digits == 53, "boost::float64_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails"); | |
376 | BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float64_t>::max_exponent == 1024, "boost::float64_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails"); | |
377 | ||
378 | #undef BOOST_CSTDFLOAT_FLOAT_64_MIN | |
379 | #undef BOOST_CSTDFLOAT_FLOAT_64_MAX | |
380 | #endif | |
381 | ||
382 | #if(BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE == 1) | |
383 | typedef BOOST_CSTDFLOAT_FLOAT80_NATIVE_TYPE float80_t; | |
384 | typedef boost::float80_t float_fast80_t; | |
385 | typedef boost::float80_t float_least80_t; | |
386 | ||
387 | BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float80_t>::is_iec559 == true, "boost::float80_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails"); | |
388 | BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float80_t>::radix == 2, "boost::float80_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails"); | |
389 | BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float80_t>::digits == 64, "boost::float80_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails"); | |
390 | BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float80_t>::max_exponent == 16384, "boost::float80_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails"); | |
391 | ||
392 | #undef BOOST_CSTDFLOAT_FLOAT_80_MIN | |
393 | #undef BOOST_CSTDFLOAT_FLOAT_80_MAX | |
394 | #endif | |
395 | ||
396 | #if(BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE == 1) | |
397 | typedef BOOST_CSTDFLOAT_FLOAT128_NATIVE_TYPE float128_t; | |
398 | typedef boost::float128_t float_fast128_t; | |
399 | typedef boost::float128_t float_least128_t; | |
400 | ||
401 | #if defined(BOOST_CSTDFLOAT_HAS_INTERNAL_FLOAT128_T) && defined(BOOST_MATH_USE_FLOAT128) && !defined(BOOST_CSTDFLOAT_NO_LIBQUADMATH_SUPPORT) | |
402 | // This configuration does not *yet* support std::numeric_limits<boost::float128_t>. | |
403 | // Support for std::numeric_limits<boost::float128_t> is added in the detail | |
404 | // file <boost/math/cstdfloat/cstdfloat_limits.hpp>. | |
405 | #else | |
406 | BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float128_t>::is_iec559 == true, "boost::float128_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails"); | |
407 | BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float128_t>::radix == 2, "boost::float128_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails"); | |
408 | BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float128_t>::digits == 113, "boost::float128_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails"); | |
409 | BOOST_STATIC_ASSERT_MSG(std::numeric_limits<boost::float128_t>::max_exponent == 16384, "boost::float128_t has been detected in <boost/cstdfloat>, but verification with std::numeric_limits fails"); | |
410 | #endif | |
411 | ||
412 | #undef BOOST_CSTDFLOAT_FLOAT_128_MIN | |
413 | #undef BOOST_CSTDFLOAT_FLOAT_128_MAX | |
414 | #endif | |
415 | ||
416 | #if (BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH == 16) | |
417 | typedef boost::float16_t floatmax_t; | |
418 | #elif(BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH == 32) | |
419 | typedef boost::float32_t floatmax_t; | |
420 | #elif(BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH == 64) | |
421 | typedef boost::float64_t floatmax_t; | |
422 | #elif(BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH == 80) | |
423 | typedef boost::float80_t floatmax_t; | |
424 | #elif(BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH == 128) | |
425 | typedef boost::float128_t floatmax_t; | |
426 | #else | |
427 | #error The maximum available floating-point width for <boost/cstdfloat.hpp> is undefined. | |
428 | #endif | |
429 | ||
430 | #undef BOOST_CSTDFLOAT_HAS_FLOAT16_NATIVE_TYPE | |
431 | #undef BOOST_CSTDFLOAT_HAS_FLOAT32_NATIVE_TYPE | |
432 | #undef BOOST_CSTDFLOAT_HAS_FLOAT64_NATIVE_TYPE | |
433 | #undef BOOST_CSTDFLOAT_HAS_FLOAT80_NATIVE_TYPE | |
434 | #undef BOOST_CSTDFLOAT_HAS_FLOAT128_NATIVE_TYPE | |
435 | ||
436 | #undef BOOST_CSTDFLOAT_MAXIMUM_AVAILABLE_WIDTH | |
437 | } | |
438 | // namespace boost | |
439 | ||
440 | #endif // _BOOST_CSTDFLOAT_BASE_TYPES_2014_01_09_HPP_ |