xref: /freebsd/contrib/llvm-project/clang/lib/Headers/float.h (revision 43a5ec4eb41567cc92586503212743d89686d78f)
1 /*===---- float.h - Characteristics of floating point types ----------------===
2  *
3  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4  * See https://llvm.org/LICENSE.txt for license information.
5  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6  *
7  *===-----------------------------------------------------------------------===
8  */
9 
10 #ifndef __CLANG_FLOAT_H
11 #define __CLANG_FLOAT_H
12 
13 /* If we're on MinGW, fall back to the system's float.h, which might have
14  * additional definitions provided for Windows.
15  * For more details see http://msdn.microsoft.com/en-us/library/y0ybw9fy.aspx
16  *
17  * Also fall back on Darwin to allow additional definitions and
18  * implementation-defined values.
19  */
20 #if (defined(__APPLE__) || (defined(__MINGW32__) || defined(_MSC_VER))) && \
21     __STDC_HOSTED__ && __has_include_next(<float.h>)
22 
23 /* Prior to Apple's 10.7 SDK, float.h SDK header used to apply an extra level
24  * of #include_next<float.h> to keep Metrowerks compilers happy. Avoid this
25  * extra indirection.
26  */
27 #ifdef __APPLE__
28 #define _FLOAT_H_
29 #endif
30 
31 #  include_next <float.h>
32 
33 /* Undefine anything that we'll be redefining below. */
34 #  undef FLT_EVAL_METHOD
35 #  undef FLT_ROUNDS
36 #  undef FLT_RADIX
37 #  undef FLT_MANT_DIG
38 #  undef DBL_MANT_DIG
39 #  undef LDBL_MANT_DIG
40 #  if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__) || __cplusplus >= 201103L
41 #    undef DECIMAL_DIG
42 #  endif
43 #  undef FLT_DIG
44 #  undef DBL_DIG
45 #  undef LDBL_DIG
46 #  undef FLT_MIN_EXP
47 #  undef DBL_MIN_EXP
48 #  undef LDBL_MIN_EXP
49 #  undef FLT_MIN_10_EXP
50 #  undef DBL_MIN_10_EXP
51 #  undef LDBL_MIN_10_EXP
52 #  undef FLT_MAX_EXP
53 #  undef DBL_MAX_EXP
54 #  undef LDBL_MAX_EXP
55 #  undef FLT_MAX_10_EXP
56 #  undef DBL_MAX_10_EXP
57 #  undef LDBL_MAX_10_EXP
58 #  undef FLT_MAX
59 #  undef DBL_MAX
60 #  undef LDBL_MAX
61 #  undef FLT_EPSILON
62 #  undef DBL_EPSILON
63 #  undef LDBL_EPSILON
64 #  undef FLT_MIN
65 #  undef DBL_MIN
66 #  undef LDBL_MIN
67 #  if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__) || __cplusplus >= 201703L
68 #    undef FLT_TRUE_MIN
69 #    undef DBL_TRUE_MIN
70 #    undef LDBL_TRUE_MIN
71 #    undef FLT_DECIMAL_DIG
72 #    undef DBL_DECIMAL_DIG
73 #    undef LDBL_DECIMAL_DIG
74 #    undef FLT_HAS_SUBNORM
75 #    undef DBL_HAS_SUBNORM
76 #    undef LDBL_HAS_SUBNORM
77 #  endif
78 #endif
79 
80 /* Characteristics of floating point types, C99 5.2.4.2.2 */
81 
82 #define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
83 #define FLT_ROUNDS (__builtin_flt_rounds())
84 #define FLT_RADIX __FLT_RADIX__
85 
86 #define FLT_MANT_DIG __FLT_MANT_DIG__
87 #define DBL_MANT_DIG __DBL_MANT_DIG__
88 #define LDBL_MANT_DIG __LDBL_MANT_DIG__
89 
90 #if __STDC_VERSION__ >= 199901L || !defined(__STRICT_ANSI__) || __cplusplus >= 201103L
91 #  define DECIMAL_DIG __DECIMAL_DIG__
92 #endif
93 
94 #define FLT_DIG __FLT_DIG__
95 #define DBL_DIG __DBL_DIG__
96 #define LDBL_DIG __LDBL_DIG__
97 
98 #define FLT_MIN_EXP __FLT_MIN_EXP__
99 #define DBL_MIN_EXP __DBL_MIN_EXP__
100 #define LDBL_MIN_EXP __LDBL_MIN_EXP__
101 
102 #define FLT_MIN_10_EXP __FLT_MIN_10_EXP__
103 #define DBL_MIN_10_EXP __DBL_MIN_10_EXP__
104 #define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__
105 
106 #define FLT_MAX_EXP __FLT_MAX_EXP__
107 #define DBL_MAX_EXP __DBL_MAX_EXP__
108 #define LDBL_MAX_EXP __LDBL_MAX_EXP__
109 
110 #define FLT_MAX_10_EXP __FLT_MAX_10_EXP__
111 #define DBL_MAX_10_EXP __DBL_MAX_10_EXP__
112 #define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__
113 
114 #define FLT_MAX __FLT_MAX__
115 #define DBL_MAX __DBL_MAX__
116 #define LDBL_MAX __LDBL_MAX__
117 
118 #define FLT_EPSILON __FLT_EPSILON__
119 #define DBL_EPSILON __DBL_EPSILON__
120 #define LDBL_EPSILON __LDBL_EPSILON__
121 
122 #define FLT_MIN __FLT_MIN__
123 #define DBL_MIN __DBL_MIN__
124 #define LDBL_MIN __LDBL_MIN__
125 
126 #if __STDC_VERSION__ >= 201112L || !defined(__STRICT_ANSI__) || __cplusplus >= 201703L
127 #  define FLT_TRUE_MIN __FLT_DENORM_MIN__
128 #  define DBL_TRUE_MIN __DBL_DENORM_MIN__
129 #  define LDBL_TRUE_MIN __LDBL_DENORM_MIN__
130 #  define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__
131 #  define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__
132 #  define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__
133 #  define FLT_HAS_SUBNORM __FLT_HAS_DENORM__
134 #  define DBL_HAS_SUBNORM __DBL_HAS_DENORM__
135 #  define LDBL_HAS_SUBNORM __LDBL_HAS_DENORM__
136 #endif
137 
138 #ifdef __STDC_WANT_IEC_60559_TYPES_EXT__
139 #  define FLT16_MANT_DIG    __FLT16_MANT_DIG__
140 #  define FLT16_DECIMAL_DIG __FLT16_DECIMAL_DIG__
141 #  define FLT16_DIG         __FLT16_DIG__
142 #  define FLT16_MIN_EXP     __FLT16_MIN_EXP__
143 #  define FLT16_MIN_10_EXP  __FLT16_MIN_10_EXP__
144 #  define FLT16_MAX_EXP     __FLT16_MAX_EXP__
145 #  define FLT16_MAX_10_EXP  __FLT16_MAX_10_EXP__
146 #  define FLT16_MAX         __FLT16_MAX__
147 #  define FLT16_EPSILON     __FLT16_EPSILON__
148 #  define FLT16_MIN         __FLT16_MIN__
149 #  define FLT16_TRUE_MIN    __FLT16_TRUE_MIN__
150 #endif /* __STDC_WANT_IEC_60559_TYPES_EXT__ */
151 
152 #endif /* __CLANG_FLOAT_H */
153