Implement C _FloatN, _FloatNx types.
[official-gcc.git] / gcc / ginclude / float.h
blobde46a2711a96e7c31f5fcb16441cc1e6da2d86f4
1 /* Copyright (C) 2002-2016 Free Software Foundation, Inc.
3 This file is part of GCC.
5 GCC is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3, or (at your option)
8 any later version.
10 GCC is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 Under Section 7 of GPL version 3, you are granted additional
16 permissions described in the GCC Runtime Library Exception, version
17 3.1, as published by the Free Software Foundation.
19 You should have received a copy of the GNU General Public License and
20 a copy of the GCC Runtime Library Exception along with this program;
21 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
22 <http://www.gnu.org/licenses/>. */
25 * ISO C Standard: 5.2.4.2.2 Characteristics of floating types <float.h>
28 #ifndef _FLOAT_H___
29 #define _FLOAT_H___
31 /* Radix of exponent representation, b. */
32 #undef FLT_RADIX
33 #define FLT_RADIX __FLT_RADIX__
35 /* Number of base-FLT_RADIX digits in the significand, p. */
36 #undef FLT_MANT_DIG
37 #undef DBL_MANT_DIG
38 #undef LDBL_MANT_DIG
39 #define FLT_MANT_DIG __FLT_MANT_DIG__
40 #define DBL_MANT_DIG __DBL_MANT_DIG__
41 #define LDBL_MANT_DIG __LDBL_MANT_DIG__
43 /* Number of decimal digits, q, such that any floating-point number with q
44 decimal digits can be rounded into a floating-point number with p radix b
45 digits and back again without change to the q decimal digits,
47 p * log10(b) if b is a power of 10
48 floor((p - 1) * log10(b)) otherwise
50 #undef FLT_DIG
51 #undef DBL_DIG
52 #undef LDBL_DIG
53 #define FLT_DIG __FLT_DIG__
54 #define DBL_DIG __DBL_DIG__
55 #define LDBL_DIG __LDBL_DIG__
57 /* Minimum int x such that FLT_RADIX**(x-1) is a normalized float, emin */
58 #undef FLT_MIN_EXP
59 #undef DBL_MIN_EXP
60 #undef LDBL_MIN_EXP
61 #define FLT_MIN_EXP __FLT_MIN_EXP__
62 #define DBL_MIN_EXP __DBL_MIN_EXP__
63 #define LDBL_MIN_EXP __LDBL_MIN_EXP__
65 /* Minimum negative integer such that 10 raised to that power is in the
66 range of normalized floating-point numbers,
68 ceil(log10(b) * (emin - 1))
70 #undef FLT_MIN_10_EXP
71 #undef DBL_MIN_10_EXP
72 #undef LDBL_MIN_10_EXP
73 #define FLT_MIN_10_EXP __FLT_MIN_10_EXP__
74 #define DBL_MIN_10_EXP __DBL_MIN_10_EXP__
75 #define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__
77 /* Maximum int x such that FLT_RADIX**(x-1) is a representable float, emax. */
78 #undef FLT_MAX_EXP
79 #undef DBL_MAX_EXP
80 #undef LDBL_MAX_EXP
81 #define FLT_MAX_EXP __FLT_MAX_EXP__
82 #define DBL_MAX_EXP __DBL_MAX_EXP__
83 #define LDBL_MAX_EXP __LDBL_MAX_EXP__
85 /* Maximum integer such that 10 raised to that power is in the range of
86 representable finite floating-point numbers,
88 floor(log10((1 - b**-p) * b**emax))
90 #undef FLT_MAX_10_EXP
91 #undef DBL_MAX_10_EXP
92 #undef LDBL_MAX_10_EXP
93 #define FLT_MAX_10_EXP __FLT_MAX_10_EXP__
94 #define DBL_MAX_10_EXP __DBL_MAX_10_EXP__
95 #define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__
97 /* Maximum representable finite floating-point number,
99 (1 - b**-p) * b**emax
101 #undef FLT_MAX
102 #undef DBL_MAX
103 #undef LDBL_MAX
104 #define FLT_MAX __FLT_MAX__
105 #define DBL_MAX __DBL_MAX__
106 #define LDBL_MAX __LDBL_MAX__
108 /* The difference between 1 and the least value greater than 1 that is
109 representable in the given floating point type, b**1-p. */
110 #undef FLT_EPSILON
111 #undef DBL_EPSILON
112 #undef LDBL_EPSILON
113 #define FLT_EPSILON __FLT_EPSILON__
114 #define DBL_EPSILON __DBL_EPSILON__
115 #define LDBL_EPSILON __LDBL_EPSILON__
117 /* Minimum normalized positive floating-point number, b**(emin - 1). */
118 #undef FLT_MIN
119 #undef DBL_MIN
120 #undef LDBL_MIN
121 #define FLT_MIN __FLT_MIN__
122 #define DBL_MIN __DBL_MIN__
123 #define LDBL_MIN __LDBL_MIN__
125 /* Addition rounds to 0: zero, 1: nearest, 2: +inf, 3: -inf, -1: unknown. */
126 /* ??? This is supposed to change with calls to fesetround in <fenv.h>. */
127 #undef FLT_ROUNDS
128 #define FLT_ROUNDS 1
130 #if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) \
131 || (defined (__cplusplus) && __cplusplus >= 201103L)
132 /* The floating-point expression evaluation method.
133 -1 indeterminate
134 0 evaluate all operations and constants just to the range and
135 precision of the type
136 1 evaluate operations and constants of type float and double
137 to the range and precision of the double type, evaluate
138 long double operations and constants to the range and
139 precision of the long double type
140 2 evaluate all operations and constants to the range and
141 precision of the long double type
143 ??? This ought to change with the setting of the fp control word;
144 the value provided by the compiler assumes the widest setting. */
145 #undef FLT_EVAL_METHOD
146 #define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
148 /* Number of decimal digits, n, such that any floating-point number in the
149 widest supported floating type with pmax radix b digits can be rounded
150 to a floating-point number with n decimal digits and back again without
151 change to the value,
153 pmax * log10(b) if b is a power of 10
154 ceil(1 + pmax * log10(b)) otherwise
156 #undef DECIMAL_DIG
157 #define DECIMAL_DIG __DECIMAL_DIG__
159 #endif /* C99 */
161 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
162 /* Versions of DECIMAL_DIG for each floating-point type. */
163 #undef FLT_DECIMAL_DIG
164 #undef DBL_DECIMAL_DIG
165 #undef LDBL_DECIMAL_DIG
166 #define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__
167 #define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__
168 #define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__
170 /* Whether types support subnormal numbers. */
171 #undef FLT_HAS_SUBNORM
172 #undef DBL_HAS_SUBNORM
173 #undef LDBL_HAS_SUBNORM
174 #define FLT_HAS_SUBNORM __FLT_HAS_DENORM__
175 #define DBL_HAS_SUBNORM __DBL_HAS_DENORM__
176 #define LDBL_HAS_SUBNORM __LDBL_HAS_DENORM__
178 /* Minimum positive values, including subnormals. */
179 #undef FLT_TRUE_MIN
180 #undef DBL_TRUE_MIN
181 #undef LDBL_TRUE_MIN
182 #define FLT_TRUE_MIN __FLT_DENORM_MIN__
183 #define DBL_TRUE_MIN __DBL_DENORM_MIN__
184 #define LDBL_TRUE_MIN __LDBL_DENORM_MIN__
186 #endif /* C11 */
188 #ifdef __STDC_WANT_IEC_60559_TYPES_EXT__
189 /* Constants for _FloatN and _FloatNx types from TS 18661-3. See
190 comments above for their semantics. */
192 #ifdef __FLT16_MANT_DIG__
193 #undef FLT16_MANT_DIG
194 #define FLT16_MANT_DIG __FLT16_MANT_DIG__
195 #undef FLT16_DIG
196 #define FLT16_DIG __FLT16_DIG__
197 #undef FLT16_MIN_EXP
198 #define FLT16_MIN_EXP __FLT16_MIN_EXP__
199 #undef FLT16_MIN_10_EXP
200 #define FLT16_MIN_10_EXP __FLT16_MIN_10_EXP__
201 #undef FLT16_MAX_EXP
202 #define FLT16_MAX_EXP __FLT16_MAX_EXP__
203 #undef FLT16_MAX_10_EXP
204 #define FLT16_MAX_10_EXP __FLT16_MAX_10_EXP__
205 #undef FLT16_MAX
206 #define FLT16_MAX __FLT16_MAX__
207 #undef FLT16_EPSILON
208 #define FLT16_EPSILON __FLT16_EPSILON__
209 #undef FLT16_MIN
210 #define FLT16_MIN __FLT16_MIN__
211 #undef FLT16_DECIMAL_DIG
212 #define FLT16_DECIMAL_DIG __FLT16_DECIMAL_DIG__
213 #undef FLT16_TRUE_MIN
214 #define FLT16_TRUE_MIN __FLT16_DENORM_MIN__
215 #endif /* __FLT16_MANT_DIG__. */
217 #ifdef __FLT32_MANT_DIG__
218 #undef FLT32_MANT_DIG
219 #define FLT32_MANT_DIG __FLT32_MANT_DIG__
220 #undef FLT32_DIG
221 #define FLT32_DIG __FLT32_DIG__
222 #undef FLT32_MIN_EXP
223 #define FLT32_MIN_EXP __FLT32_MIN_EXP__
224 #undef FLT32_MIN_10_EXP
225 #define FLT32_MIN_10_EXP __FLT32_MIN_10_EXP__
226 #undef FLT32_MAX_EXP
227 #define FLT32_MAX_EXP __FLT32_MAX_EXP__
228 #undef FLT32_MAX_10_EXP
229 #define FLT32_MAX_10_EXP __FLT32_MAX_10_EXP__
230 #undef FLT32_MAX
231 #define FLT32_MAX __FLT32_MAX__
232 #undef FLT32_EPSILON
233 #define FLT32_EPSILON __FLT32_EPSILON__
234 #undef FLT32_MIN
235 #define FLT32_MIN __FLT32_MIN__
236 #undef FLT32_DECIMAL_DIG
237 #define FLT32_DECIMAL_DIG __FLT32_DECIMAL_DIG__
238 #undef FLT32_TRUE_MIN
239 #define FLT32_TRUE_MIN __FLT32_DENORM_MIN__
240 #endif /* __FLT32_MANT_DIG__. */
242 #ifdef __FLT64_MANT_DIG__
243 #undef FLT64_MANT_DIG
244 #define FLT64_MANT_DIG __FLT64_MANT_DIG__
245 #undef FLT64_DIG
246 #define FLT64_DIG __FLT64_DIG__
247 #undef FLT64_MIN_EXP
248 #define FLT64_MIN_EXP __FLT64_MIN_EXP__
249 #undef FLT64_MIN_10_EXP
250 #define FLT64_MIN_10_EXP __FLT64_MIN_10_EXP__
251 #undef FLT64_MAX_EXP
252 #define FLT64_MAX_EXP __FLT64_MAX_EXP__
253 #undef FLT64_MAX_10_EXP
254 #define FLT64_MAX_10_EXP __FLT64_MAX_10_EXP__
255 #undef FLT64_MAX
256 #define FLT64_MAX __FLT64_MAX__
257 #undef FLT64_EPSILON
258 #define FLT64_EPSILON __FLT64_EPSILON__
259 #undef FLT64_MIN
260 #define FLT64_MIN __FLT64_MIN__
261 #undef FLT64_DECIMAL_DIG
262 #define FLT64_DECIMAL_DIG __FLT64_DECIMAL_DIG__
263 #undef FLT64_TRUE_MIN
264 #define FLT64_TRUE_MIN __FLT64_DENORM_MIN__
265 #endif /* __FLT64_MANT_DIG__. */
267 #ifdef __FLT128_MANT_DIG__
268 #undef FLT128_MANT_DIG
269 #define FLT128_MANT_DIG __FLT128_MANT_DIG__
270 #undef FLT128_DIG
271 #define FLT128_DIG __FLT128_DIG__
272 #undef FLT128_MIN_EXP
273 #define FLT128_MIN_EXP __FLT128_MIN_EXP__
274 #undef FLT128_MIN_10_EXP
275 #define FLT128_MIN_10_EXP __FLT128_MIN_10_EXP__
276 #undef FLT128_MAX_EXP
277 #define FLT128_MAX_EXP __FLT128_MAX_EXP__
278 #undef FLT128_MAX_10_EXP
279 #define FLT128_MAX_10_EXP __FLT128_MAX_10_EXP__
280 #undef FLT128_MAX
281 #define FLT128_MAX __FLT128_MAX__
282 #undef FLT128_EPSILON
283 #define FLT128_EPSILON __FLT128_EPSILON__
284 #undef FLT128_MIN
285 #define FLT128_MIN __FLT128_MIN__
286 #undef FLT128_DECIMAL_DIG
287 #define FLT128_DECIMAL_DIG __FLT128_DECIMAL_DIG__
288 #undef FLT128_TRUE_MIN
289 #define FLT128_TRUE_MIN __FLT128_DENORM_MIN__
290 #endif /* __FLT128_MANT_DIG__. */
292 #ifdef __FLT32X_MANT_DIG__
293 #undef FLT32X_MANT_DIG
294 #define FLT32X_MANT_DIG __FLT32X_MANT_DIG__
295 #undef FLT32X_DIG
296 #define FLT32X_DIG __FLT32X_DIG__
297 #undef FLT32X_MIN_EXP
298 #define FLT32X_MIN_EXP __FLT32X_MIN_EXP__
299 #undef FLT32X_MIN_10_EXP
300 #define FLT32X_MIN_10_EXP __FLT32X_MIN_10_EXP__
301 #undef FLT32X_MAX_EXP
302 #define FLT32X_MAX_EXP __FLT32X_MAX_EXP__
303 #undef FLT32X_MAX_10_EXP
304 #define FLT32X_MAX_10_EXP __FLT32X_MAX_10_EXP__
305 #undef FLT32X_MAX
306 #define FLT32X_MAX __FLT32X_MAX__
307 #undef FLT32X_EPSILON
308 #define FLT32X_EPSILON __FLT32X_EPSILON__
309 #undef FLT32X_MIN
310 #define FLT32X_MIN __FLT32X_MIN__
311 #undef FLT32X_DECIMAL_DIG
312 #define FLT32X_DECIMAL_DIG __FLT32X_DECIMAL_DIG__
313 #undef FLT32X_TRUE_MIN
314 #define FLT32X_TRUE_MIN __FLT32X_DENORM_MIN__
315 #endif /* __FLT32X_MANT_DIG__. */
317 #ifdef __FLT64X_MANT_DIG__
318 #undef FLT64X_MANT_DIG
319 #define FLT64X_MANT_DIG __FLT64X_MANT_DIG__
320 #undef FLT64X_DIG
321 #define FLT64X_DIG __FLT64X_DIG__
322 #undef FLT64X_MIN_EXP
323 #define FLT64X_MIN_EXP __FLT64X_MIN_EXP__
324 #undef FLT64X_MIN_10_EXP
325 #define FLT64X_MIN_10_EXP __FLT64X_MIN_10_EXP__
326 #undef FLT64X_MAX_EXP
327 #define FLT64X_MAX_EXP __FLT64X_MAX_EXP__
328 #undef FLT64X_MAX_10_EXP
329 #define FLT64X_MAX_10_EXP __FLT64X_MAX_10_EXP__
330 #undef FLT64X_MAX
331 #define FLT64X_MAX __FLT64X_MAX__
332 #undef FLT64X_EPSILON
333 #define FLT64X_EPSILON __FLT64X_EPSILON__
334 #undef FLT64X_MIN
335 #define FLT64X_MIN __FLT64X_MIN__
336 #undef FLT64X_DECIMAL_DIG
337 #define FLT64X_DECIMAL_DIG __FLT64X_DECIMAL_DIG__
338 #undef FLT64X_TRUE_MIN
339 #define FLT64X_TRUE_MIN __FLT64X_DENORM_MIN__
340 #endif /* __FLT64X_MANT_DIG__. */
342 #ifdef __FLT128X_MANT_DIG__
343 #undef FLT128X_MANT_DIG
344 #define FLT128X_MANT_DIG __FLT128X_MANT_DIG__
345 #undef FLT128X_DIG
346 #define FLT128X_DIG __FLT128X_DIG__
347 #undef FLT128X_MIN_EXP
348 #define FLT128X_MIN_EXP __FLT128X_MIN_EXP__
349 #undef FLT128X_MIN_10_EXP
350 #define FLT128X_MIN_10_EXP __FLT128X_MIN_10_EXP__
351 #undef FLT128X_MAX_EXP
352 #define FLT128X_MAX_EXP __FLT128X_MAX_EXP__
353 #undef FLT128X_MAX_10_EXP
354 #define FLT128X_MAX_10_EXP __FLT128X_MAX_10_EXP__
355 #undef FLT128X_MAX
356 #define FLT128X_MAX __FLT128X_MAX__
357 #undef FLT128X_EPSILON
358 #define FLT128X_EPSILON __FLT128X_EPSILON__
359 #undef FLT128X_MIN
360 #define FLT128X_MIN __FLT128X_MIN__
361 #undef FLT128X_DECIMAL_DIG
362 #define FLT128X_DECIMAL_DIG __FLT128X_DECIMAL_DIG__
363 #undef FLT128X_TRUE_MIN
364 #define FLT128X_TRUE_MIN __FLT128X_DENORM_MIN__
365 #endif /* __FLT128X_MANT_DIG__. */
367 #endif /* __STDC_WANT_IEC_60559_TYPES_EXT__. */
369 #ifdef __STDC_WANT_DEC_FP__
370 /* Draft Technical Report 24732, extension for decimal floating-point
371 arithmetic: Characteristic of decimal floating types <float.h>. */
373 /* Number of base-FLT_RADIX digits in the significand, p. */
374 #undef DEC32_MANT_DIG
375 #undef DEC64_MANT_DIG
376 #undef DEC128_MANT_DIG
377 #define DEC32_MANT_DIG __DEC32_MANT_DIG__
378 #define DEC64_MANT_DIG __DEC64_MANT_DIG__
379 #define DEC128_MANT_DIG __DEC128_MANT_DIG__
381 /* Minimum exponent. */
382 #undef DEC32_MIN_EXP
383 #undef DEC64_MIN_EXP
384 #undef DEC128_MIN_EXP
385 #define DEC32_MIN_EXP __DEC32_MIN_EXP__
386 #define DEC64_MIN_EXP __DEC64_MIN_EXP__
387 #define DEC128_MIN_EXP __DEC128_MIN_EXP__
389 /* Maximum exponent. */
390 #undef DEC32_MAX_EXP
391 #undef DEC64_MAX_EXP
392 #undef DEC128_MAX_EXP
393 #define DEC32_MAX_EXP __DEC32_MAX_EXP__
394 #define DEC64_MAX_EXP __DEC64_MAX_EXP__
395 #define DEC128_MAX_EXP __DEC128_MAX_EXP__
397 /* Maximum representable finite decimal floating-point number
398 (there are 6, 15, and 33 9s after the decimal points respectively). */
399 #undef DEC32_MAX
400 #undef DEC64_MAX
401 #undef DEC128_MAX
402 #define DEC32_MAX __DEC32_MAX__
403 #define DEC64_MAX __DEC64_MAX__
404 #define DEC128_MAX __DEC128_MAX__
406 /* The difference between 1 and the least value greater than 1 that is
407 representable in the given floating point type. */
408 #undef DEC32_EPSILON
409 #undef DEC64_EPSILON
410 #undef DEC128_EPSILON
411 #define DEC32_EPSILON __DEC32_EPSILON__
412 #define DEC64_EPSILON __DEC64_EPSILON__
413 #define DEC128_EPSILON __DEC128_EPSILON__
415 /* Minimum normalized positive floating-point number. */
416 #undef DEC32_MIN
417 #undef DEC64_MIN
418 #undef DEC128_MIN
419 #define DEC32_MIN __DEC32_MIN__
420 #define DEC64_MIN __DEC64_MIN__
421 #define DEC128_MIN __DEC128_MIN__
423 /* Minimum subnormal positive floating-point number. */
424 #undef DEC32_SUBNORMAL_MIN
425 #undef DEC64_SUBNORMAL_MIN
426 #undef DEC128_SUBNORMAL_MIN
427 #define DEC32_SUBNORMAL_MIN __DEC32_SUBNORMAL_MIN__
428 #define DEC64_SUBNORMAL_MIN __DEC64_SUBNORMAL_MIN__
429 #define DEC128_SUBNORMAL_MIN __DEC128_SUBNORMAL_MIN__
431 /* The floating-point expression evaluation method.
432 -1 indeterminate
433 0 evaluate all operations and constants just to the range and
434 precision of the type
435 1 evaluate operations and constants of type _Decimal32
436 and _Decimal64 to the range and precision of the _Decimal64
437 type, evaluate _Decimal128 operations and constants to the
438 range and precision of the _Decimal128 type;
439 2 evaluate all operations and constants to the range and
440 precision of the _Decimal128 type. */
442 #undef DEC_EVAL_METHOD
443 #define DEC_EVAL_METHOD __DEC_EVAL_METHOD__
445 #endif /* __STDC_WANT_DEC_FP__ */
447 #endif /* _FLOAT_H___ */