clang 22.0.0git
float.h
Go to the documentation of this file.
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 defined(__MVS__) && __has_include_next(<float.h>)
14#include_next <float.h>
15#else
16
17/* If we're on MinGW, fall back to the system's float.h, which might have
18 * additional definitions provided for Windows.
19 * For more details see http://msdn.microsoft.com/en-us/library/y0ybw9fy.aspx
20 *
21 * Also fall back on AIX to allow additional definitions and
22 * implementation-defined values.
23 */
24#if (defined(__MINGW32__) || defined(_MSC_VER) || defined(_AIX)) && \
25 __STDC_HOSTED__ && __has_include_next(<float.h>)
26
27# include_next <float.h>
28
29/* Undefine anything that we'll be redefining below. */
30# undef FLT_EVAL_METHOD
31# undef FLT_ROUNDS
32# undef FLT_RADIX
33# undef FLT_MANT_DIG
34# undef DBL_MANT_DIG
35# undef LDBL_MANT_DIG
36#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
37 !defined(__STRICT_ANSI__) || \
38 (defined(__cplusplus) && __cplusplus >= 201103L) || \
39 (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE))
40# undef DECIMAL_DIG
41# endif
42# undef FLT_DIG
43# undef DBL_DIG
44# undef LDBL_DIG
45# undef FLT_MIN_EXP
46# undef DBL_MIN_EXP
47# undef LDBL_MIN_EXP
48# undef FLT_MIN_10_EXP
49# undef DBL_MIN_10_EXP
50# undef LDBL_MIN_10_EXP
51# undef FLT_MAX_EXP
52# undef DBL_MAX_EXP
53# undef LDBL_MAX_EXP
54# undef FLT_MAX_10_EXP
55# undef DBL_MAX_10_EXP
56# undef LDBL_MAX_10_EXP
57# undef FLT_MAX
58# undef DBL_MAX
59# undef LDBL_MAX
60# undef FLT_EPSILON
61# undef DBL_EPSILON
62# undef LDBL_EPSILON
63# undef FLT_MIN
64# undef DBL_MIN
65# undef LDBL_MIN
66#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
67 !defined(__STRICT_ANSI__) || \
68 (defined(__cplusplus) && __cplusplus >= 201703L) || \
69 (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE))
70# undef FLT_TRUE_MIN
71# undef DBL_TRUE_MIN
72# undef LDBL_TRUE_MIN
73# undef FLT_DECIMAL_DIG
74# undef DBL_DECIMAL_DIG
75# undef LDBL_DECIMAL_DIG
76# undef FLT_HAS_SUBNORM
77# undef DBL_HAS_SUBNORM
78# undef LDBL_HAS_SUBNORM
79# endif
80#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) || \
81 !defined(__STRICT_ANSI__)
82# undef FLT_NORM_MAX
83# undef DBL_NORM_MAX
84# undef LDBL_NORM_MAX
85#endif
86#endif
87
88#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) || \
89 !defined(__STRICT_ANSI__)
90# undef INFINITY
91# undef NAN
92#endif
93
94/* Characteristics of floating point types, C99 5.2.4.2.2 */
95
96#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
97 (defined(__cplusplus) && __cplusplus >= 201103L)
98#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
99#endif
100#define FLT_ROUNDS (__builtin_flt_rounds())
101#define FLT_RADIX __FLT_RADIX__
102
103#define FLT_MANT_DIG __FLT_MANT_DIG__
104#define DBL_MANT_DIG __DBL_MANT_DIG__
105#define LDBL_MANT_DIG __LDBL_MANT_DIG__
106
107#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
108 !defined(__STRICT_ANSI__) || \
109 (defined(__cplusplus) && __cplusplus >= 201103L) || \
110 (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE))
111# define DECIMAL_DIG __DECIMAL_DIG__
112#endif
113
114#define FLT_DIG __FLT_DIG__
115#define DBL_DIG __DBL_DIG__
116#define LDBL_DIG __LDBL_DIG__
117
118#define FLT_MIN_EXP __FLT_MIN_EXP__
119#define DBL_MIN_EXP __DBL_MIN_EXP__
120#define LDBL_MIN_EXP __LDBL_MIN_EXP__
121
122#define FLT_MIN_10_EXP __FLT_MIN_10_EXP__
123#define DBL_MIN_10_EXP __DBL_MIN_10_EXP__
124#define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__
125
126#define FLT_MAX_EXP __FLT_MAX_EXP__
127#define DBL_MAX_EXP __DBL_MAX_EXP__
128#define LDBL_MAX_EXP __LDBL_MAX_EXP__
129
130#define FLT_MAX_10_EXP __FLT_MAX_10_EXP__
131#define DBL_MAX_10_EXP __DBL_MAX_10_EXP__
132#define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__
133
134#define FLT_MAX __FLT_MAX__
135#define DBL_MAX __DBL_MAX__
136#define LDBL_MAX __LDBL_MAX__
137
138#define FLT_EPSILON __FLT_EPSILON__
139#define DBL_EPSILON __DBL_EPSILON__
140#define LDBL_EPSILON __LDBL_EPSILON__
141
142#define FLT_MIN __FLT_MIN__
143#define DBL_MIN __DBL_MIN__
144#define LDBL_MIN __LDBL_MIN__
145
146#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) || \
147 !defined(__STRICT_ANSI__) || \
148 (defined(__cplusplus) && __cplusplus >= 201703L) || \
149 (__STDC_HOSTED__ && defined(_AIX) && defined(_ALL_SOURCE))
150# define FLT_TRUE_MIN __FLT_DENORM_MIN__
151# define DBL_TRUE_MIN __DBL_DENORM_MIN__
152# define LDBL_TRUE_MIN __LDBL_DENORM_MIN__
153# define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__
154# define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__
155# define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__
156# define FLT_HAS_SUBNORM __FLT_HAS_DENORM__
157# define DBL_HAS_SUBNORM __DBL_HAS_DENORM__
158# define LDBL_HAS_SUBNORM __LDBL_HAS_DENORM__
159#endif
160
161#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) || \
162 !defined(__STRICT_ANSI__)
163 /* C23 5.2.5.3.3p29-30 */
164# define INFINITY (__builtin_inff())
165# define NAN (__builtin_nanf(""))
166 /* C23 5.2.5.3.3p32 */
167# define FLT_NORM_MAX __FLT_NORM_MAX__
168# define DBL_NORM_MAX __DBL_NORM_MAX__
169# define LDBL_NORM_MAX __LDBL_NORM_MAX__
170#endif
171
172#ifdef __STDC_WANT_IEC_60559_TYPES_EXT__
173# define FLT16_MANT_DIG __FLT16_MANT_DIG__
174# define FLT16_DECIMAL_DIG __FLT16_DECIMAL_DIG__
175# define FLT16_DIG __FLT16_DIG__
176# define FLT16_MIN_EXP __FLT16_MIN_EXP__
177# define FLT16_MIN_10_EXP __FLT16_MIN_10_EXP__
178# define FLT16_MAX_EXP __FLT16_MAX_EXP__
179# define FLT16_MAX_10_EXP __FLT16_MAX_10_EXP__
180# define FLT16_MAX __FLT16_MAX__
181# define FLT16_EPSILON __FLT16_EPSILON__
182# define FLT16_MIN __FLT16_MIN__
183# define FLT16_TRUE_MIN __FLT16_TRUE_MIN__
184#endif /* __STDC_WANT_IEC_60559_TYPES_EXT__ */
185
186#endif /* __MVS__ */
187#endif /* __CLANG_FLOAT_H */