1 /*===---- float.h - Characteristics of floating point types ----------------===
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
7 *===-----------------------------------------------------------------------===
10 #ifndef __CLANG_FLOAT_H
11 #define __CLANG_FLOAT_H
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
17 * Also fall back on Darwin and AIX to allow additional definitions and
18 * implementation-defined values.
20 #if (defined(__APPLE__) || defined(__MINGW32__) || defined(_MSC_VER) || \
22 __STDC_HOSTED__ && __has_include_next(<float.h>)
24 /* Prior to Apple's 10.7 SDK, float.h SDK header used to apply an extra level
25 * of #include_next<float.h> to keep Metrowerks compilers happy. Avoid this
32 # include_next <float.h>
34 /* Undefine anything that we'll be redefining below. */
35 # undef FLT_EVAL_METHOD
41 #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
42 !defined(__STRICT_ANSI__) || \
43 (defined(__cplusplus) && __cplusplus >= 201103L) || \
44 (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE))
53 # undef FLT_MIN_10_EXP
54 # undef DBL_MIN_10_EXP
55 # undef LDBL_MIN_10_EXP
59 # undef FLT_MAX_10_EXP
60 # undef DBL_MAX_10_EXP
61 # undef LDBL_MAX_10_EXP
71 #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
72 !defined(__STRICT_ANSI__) || \
73 (defined(__cplusplus) && __cplusplus >= 201703L) || \
74 (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE))
78 # undef FLT_DECIMAL_DIG
79 # undef DBL_DECIMAL_DIG
80 # undef LDBL_DECIMAL_DIG
81 # undef FLT_HAS_SUBNORM
82 # undef DBL_HAS_SUBNORM
83 # undef LDBL_HAS_SUBNORM
87 /* Characteristics of floating point types, C99 5.2.4.2.2 */
89 #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
90 (defined(__cplusplus) && __cplusplus >= 201103L)
91 #define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
93 #define FLT_ROUNDS (__builtin_flt_rounds())
94 #define FLT_RADIX __FLT_RADIX__
96 #define FLT_MANT_DIG __FLT_MANT_DIG__
97 #define DBL_MANT_DIG __DBL_MANT_DIG__
98 #define LDBL_MANT_DIG __LDBL_MANT_DIG__
100 #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
101 !defined(__STRICT_ANSI__) || \
102 (defined(__cplusplus) && __cplusplus >= 201103L) || \
103 (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE))
104 # define DECIMAL_DIG __DECIMAL_DIG__
107 #define FLT_DIG __FLT_DIG__
108 #define DBL_DIG __DBL_DIG__
109 #define LDBL_DIG __LDBL_DIG__
111 #define FLT_MIN_EXP __FLT_MIN_EXP__
112 #define DBL_MIN_EXP __DBL_MIN_EXP__
113 #define LDBL_MIN_EXP __LDBL_MIN_EXP__
115 #define FLT_MIN_10_EXP __FLT_MIN_10_EXP__
116 #define DBL_MIN_10_EXP __DBL_MIN_10_EXP__
117 #define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__
119 #define FLT_MAX_EXP __FLT_MAX_EXP__
120 #define DBL_MAX_EXP __DBL_MAX_EXP__
121 #define LDBL_MAX_EXP __LDBL_MAX_EXP__
123 #define FLT_MAX_10_EXP __FLT_MAX_10_EXP__
124 #define DBL_MAX_10_EXP __DBL_MAX_10_EXP__
125 #define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__
127 #define FLT_MAX __FLT_MAX__
128 #define DBL_MAX __DBL_MAX__
129 #define LDBL_MAX __LDBL_MAX__
131 #define FLT_EPSILON __FLT_EPSILON__
132 #define DBL_EPSILON __DBL_EPSILON__
133 #define LDBL_EPSILON __LDBL_EPSILON__
135 #define FLT_MIN __FLT_MIN__
136 #define DBL_MIN __DBL_MIN__
137 #define LDBL_MIN __LDBL_MIN__
139 #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
140 !defined(__STRICT_ANSI__) || \
141 (defined(__cplusplus) && __cplusplus >= 201703L) || \
142 (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE))
143 # define FLT_TRUE_MIN __FLT_DENORM_MIN__
144 # define DBL_TRUE_MIN __DBL_DENORM_MIN__
145 # define LDBL_TRUE_MIN __LDBL_DENORM_MIN__
146 # define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__
147 # define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__
148 # define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__
149 # define FLT_HAS_SUBNORM __FLT_HAS_DENORM__
150 # define DBL_HAS_SUBNORM __DBL_HAS_DENORM__
151 # define LDBL_HAS_SUBNORM __LDBL_HAS_DENORM__
154 #ifdef __STDC_WANT_IEC_60559_TYPES_EXT__
155 # define FLT16_MANT_DIG __FLT16_MANT_DIG__
156 # define FLT16_DECIMAL_DIG __FLT16_DECIMAL_DIG__
157 # define FLT16_DIG __FLT16_DIG__
158 # define FLT16_MIN_EXP __FLT16_MIN_EXP__
159 # define FLT16_MIN_10_EXP __FLT16_MIN_10_EXP__
160 # define FLT16_MAX_EXP __FLT16_MAX_EXP__
161 # define FLT16_MAX_10_EXP __FLT16_MAX_10_EXP__
162 # define FLT16_MAX __FLT16_MAX__
163 # define FLT16_EPSILON __FLT16_EPSILON__
164 # define FLT16_MIN __FLT16_MIN__
165 # define FLT16_TRUE_MIN __FLT16_TRUE_MIN__
166 #endif /* __STDC_WANT_IEC_60559_TYPES_EXT__ */
168 #endif /* __CLANG_FLOAT_H */