QtBase  v6.3.1
qfloat16.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2021 The Qt Company Ltd.
4 ** Copyright (C) 2016 by Southwest Research Institute (R)
5 ** Contact: http://www.qt-project.org/legal
6 **
7 ** This file is part of the QtCore module of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** Commercial License Usage
11 ** Licensees holding valid commercial Qt licenses may use this file in
12 ** accordance with the commercial license agreement provided with the
13 ** Software or, alternatively, in accordance with the terms contained in
14 ** a written agreement between you and The Qt Company. For licensing terms
15 ** and conditions see https://www.qt.io/terms-conditions. For further
16 ** information use the contact form at https://www.qt.io/contact-us.
17 **
18 ** GNU Lesser General Public License Usage
19 ** Alternatively, this file may be used under the terms of the GNU Lesser
20 ** General Public License version 3 as published by the Free Software
21 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
22 ** packaging of this file. Please review the following information to
23 ** ensure the GNU Lesser General Public License version 3 requirements
24 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
25 **
26 ** GNU General Public License Usage
27 ** Alternatively, this file may be used under the terms of the GNU
28 ** General Public License version 2.0 or (at your option) the GNU General
29 ** Public license version 3 or any later version approved by the KDE Free
30 ** Qt Foundation. The licenses are as published by the Free Software
31 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
32 ** included in the packaging of this file. Please review the following
33 ** information to ensure the GNU General Public License requirements will
34 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
35 ** https://www.gnu.org/licenses/gpl-3.0.html.
36 **
37 ** $QT_END_LICENSE$
38 **
39 ****************************************************************************/
40 
41 #ifndef QFLOAT16_H
42 #define QFLOAT16_H
43 
44 #include <QtCore/qglobal.h>
45 #include <QtCore/qmetatype.h>
46 #include <QtCore/qnamespace.h>
47 #include <limits>
48 #include <string.h>
49 
50 #if defined(QT_COMPILER_SUPPORTS_F16C) && defined(__AVX2__) && !defined(__F16C__)
51 // All processors that support AVX2 do support F16C too. That doesn't mean
52 // we're allowed to use the intrinsics directly, so we'll do it only for
53 // the Intel and Microsoft's compilers.
54 # if defined(Q_CC_INTEL) || defined(Q_CC_MSVC)
55 # define __F16C__ 1
56 # endif
57 #endif
58 
59 #if defined(QT_COMPILER_SUPPORTS_F16C) && defined(__F16C__)
60 #include <immintrin.h>
61 #endif
62 
64 
65 #if 0
66 #pragma qt_class(QFloat16)
67 #pragma qt_no_master_include
68 #endif
69 
70 #ifndef QT_NO_DATASTREAM
71 class QDataStream;
72 #endif
73 
74 class qfloat16
75 {
76  struct Wrap
77  {
78  // To let our private constructor work, without other code seeing
79  // ambiguity when constructing from int, double &c.
80  quint16 b16;
81  constexpr inline explicit Wrap(int value) : b16(quint16(value)) {}
82  };
83 public:
84  constexpr inline qfloat16() noexcept : b16(0) {}
85  explicit qfloat16(Qt::Initialization) noexcept { }
86  inline qfloat16(float f) noexcept;
87  inline operator float() const noexcept;
88 
89  // Support for qIs{Inf,NaN,Finite}:
90  bool isInf() const noexcept { return (b16 & 0x7fff) == 0x7c00; }
91  bool isNaN() const noexcept { return (b16 & 0x7fff) > 0x7c00; }
92  bool isFinite() const noexcept { return (b16 & 0x7fff) < 0x7c00; }
93  Q_CORE_EXPORT int fpClassify() const noexcept;
94  // Can't specialize std::copysign() for qfloat16
96  { return qfloat16(Wrap((sign.b16 & 0x8000) | (b16 & 0x7fff))); }
97  // Support for std::numeric_limits<qfloat16>
98  static constexpr qfloat16 _limit_epsilon() noexcept { return qfloat16(Wrap(0x1400)); }
99  static constexpr qfloat16 _limit_min() noexcept { return qfloat16(Wrap(0x400)); }
100  static constexpr qfloat16 _limit_denorm_min() noexcept { return qfloat16(Wrap(1)); }
101  static constexpr qfloat16 _limit_max() noexcept { return qfloat16(Wrap(0x7bff)); }
102  static constexpr qfloat16 _limit_lowest() noexcept { return qfloat16(Wrap(0xfbff)); }
103  static constexpr qfloat16 _limit_infinity() noexcept { return qfloat16(Wrap(0x7c00)); }
104  static constexpr qfloat16 _limit_quiet_NaN() noexcept { return qfloat16(Wrap(0x7e00)); }
105 #if QT_CONFIG(signaling_nan)
106  static constexpr qfloat16 _limit_signaling_NaN() noexcept { return qfloat16(Wrap(0x7d00)); }
107 #endif
108  inline constexpr bool isNormal() const noexcept
109  { return (b16 & 0x7c00) && (b16 & 0x7c00) != 0x7c00; }
110 private:
111  quint16 b16;
112  constexpr inline explicit qfloat16(Wrap nibble) noexcept : b16(nibble.b16) {}
113 
114  Q_CORE_EXPORT static const quint32 mantissatable[];
115  Q_CORE_EXPORT static const quint32 exponenttable[];
116  Q_CORE_EXPORT static const quint32 offsettable[];
117  Q_CORE_EXPORT static const quint16 basetable[];
118  Q_CORE_EXPORT static const quint16 shifttable[];
119  Q_CORE_EXPORT static const quint32 roundtable[];
120 
121  friend bool qIsNull(qfloat16 f) noexcept;
122 
123  friend inline qfloat16 operator-(qfloat16 a) noexcept
124  {
125  qfloat16 f;
126  f.b16 = a.b16 ^ quint16(0x8000);
127  return f;
128  }
129 
130  friend inline qfloat16 operator+(qfloat16 a, qfloat16 b) noexcept { return qfloat16(static_cast<float>(a) + static_cast<float>(b)); }
131  friend inline qfloat16 operator-(qfloat16 a, qfloat16 b) noexcept { return qfloat16(static_cast<float>(a) - static_cast<float>(b)); }
132  friend inline qfloat16 operator*(qfloat16 a, qfloat16 b) noexcept { return qfloat16(static_cast<float>(a) * static_cast<float>(b)); }
133  friend inline qfloat16 operator/(qfloat16 a, qfloat16 b) noexcept { return qfloat16(static_cast<float>(a) / static_cast<float>(b)); }
134 
135 #define QF16_MAKE_ARITH_OP_FP(FP, OP) \
136  friend inline FP operator OP(qfloat16 lhs, FP rhs) noexcept { return static_cast<FP>(lhs) OP rhs; } \
137  friend inline FP operator OP(FP lhs, qfloat16 rhs) noexcept { return lhs OP static_cast<FP>(rhs); }
138 #define QF16_MAKE_ARITH_OP_EQ_FP(FP, OP_EQ, OP) \
139  friend inline qfloat16& operator OP_EQ(qfloat16& lhs, FP rhs) noexcept \
140  { lhs = qfloat16(float(static_cast<FP>(lhs) OP rhs)); return lhs; }
141 #define QF16_MAKE_ARITH_OP(FP) \
142  QF16_MAKE_ARITH_OP_FP(FP, +) \
143  QF16_MAKE_ARITH_OP_FP(FP, -) \
144  QF16_MAKE_ARITH_OP_FP(FP, *) \
145  QF16_MAKE_ARITH_OP_FP(FP, /) \
146  QF16_MAKE_ARITH_OP_EQ_FP(FP, +=, +) \
147  QF16_MAKE_ARITH_OP_EQ_FP(FP, -=, -) \
148  QF16_MAKE_ARITH_OP_EQ_FP(FP, *=, *) \
149  QF16_MAKE_ARITH_OP_EQ_FP(FP, /=, /)
150 
151  QF16_MAKE_ARITH_OP(long double)
152  QF16_MAKE_ARITH_OP(double)
153  QF16_MAKE_ARITH_OP(float)
154 #undef QF16_MAKE_ARITH_OP
155 #undef QF16_MAKE_ARITH_OP_FP
156 
157 #define QF16_MAKE_ARITH_OP_INT(OP) \
158  friend inline double operator OP(qfloat16 lhs, int rhs) noexcept { return static_cast<double>(lhs) OP rhs; } \
159  friend inline double operator OP(int lhs, qfloat16 rhs) noexcept { return lhs OP static_cast<double>(rhs); }
160 
165 #undef QF16_MAKE_ARITH_OP_INT
166 
169 
170  friend inline bool operator>(qfloat16 a, qfloat16 b) noexcept { return static_cast<float>(a) > static_cast<float>(b); }
171  friend inline bool operator<(qfloat16 a, qfloat16 b) noexcept { return static_cast<float>(a) < static_cast<float>(b); }
172  friend inline bool operator>=(qfloat16 a, qfloat16 b) noexcept { return static_cast<float>(a) >= static_cast<float>(b); }
173  friend inline bool operator<=(qfloat16 a, qfloat16 b) noexcept { return static_cast<float>(a) <= static_cast<float>(b); }
174  friend inline bool operator==(qfloat16 a, qfloat16 b) noexcept { return static_cast<float>(a) == static_cast<float>(b); }
175  friend inline bool operator!=(qfloat16 a, qfloat16 b) noexcept { return static_cast<float>(a) != static_cast<float>(b); }
176 
177 #define QF16_MAKE_BOOL_OP_FP(FP, OP) \
178  friend inline bool operator OP(qfloat16 lhs, FP rhs) noexcept { return static_cast<FP>(lhs) OP rhs; } \
179  friend inline bool operator OP(FP lhs, qfloat16 rhs) noexcept { return lhs OP static_cast<FP>(rhs); }
180 #define QF16_MAKE_BOOL_OP(FP) \
181  QF16_MAKE_BOOL_OP_FP(FP, <) \
182  QF16_MAKE_BOOL_OP_FP(FP, >) \
183  QF16_MAKE_BOOL_OP_FP(FP, >=) \
184  QF16_MAKE_BOOL_OP_FP(FP, <=) \
185  QF16_MAKE_BOOL_OP_FP(FP, ==) \
186  QF16_MAKE_BOOL_OP_FP(FP, !=)
187 
188  QF16_MAKE_BOOL_OP(long double)
189  QF16_MAKE_BOOL_OP(double)
190  QF16_MAKE_BOOL_OP(float)
191 #undef QF16_MAKE_BOOL_OP
192 #undef QF16_MAKE_BOOL_OP_FP
193 
194 #define QF16_MAKE_BOOL_OP_INT(OP) \
195  friend inline bool operator OP(qfloat16 a, int b) noexcept { return static_cast<float>(a) OP static_cast<float>(b); } \
196  friend inline bool operator OP(int a, qfloat16 b) noexcept { return static_cast<float>(a) OP static_cast<float>(b); }
197 
204 #undef QF16_MAKE_BOOL_OP_INT
205 
207 
208 #ifndef QT_NO_DATASTREAM
209  friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &ds, qfloat16 f);
210  friend Q_CORE_EXPORT QDataStream &operator>>(QDataStream &ds, qfloat16 &f);
211 #endif
212 };
213 
215 
216 Q_CORE_EXPORT void qFloatToFloat16(qfloat16 *, const float *, qsizetype length) noexcept;
217 Q_CORE_EXPORT void qFloatFromFloat16(float *, const qfloat16 *, qsizetype length) noexcept;
218 
219 // Complement qnumeric.h:
220 [[nodiscard]] inline bool qIsInf(qfloat16 f) noexcept { return f.isInf(); }
221 [[nodiscard]] inline bool qIsNaN(qfloat16 f) noexcept { return f.isNaN(); }
222 [[nodiscard]] inline bool qIsFinite(qfloat16 f) noexcept { return f.isFinite(); }
223 [[nodiscard]] inline int qFpClassify(qfloat16 f) noexcept { return f.fpClassify(); }
224 // [[nodiscard]] quint32 qFloatDistance(qfloat16 a, qfloat16 b);
225 
226 // The remainder of these utility functions complement qglobal.h
227 [[nodiscard]] inline int qRound(qfloat16 d) noexcept
228 { return qRound(static_cast<float>(d)); }
229 
230 [[nodiscard]] inline qint64 qRound64(qfloat16 d) noexcept
231 { return qRound64(static_cast<float>(d)); }
232 
233 [[nodiscard]] inline bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
234 {
235  float f1 = static_cast<float>(p1);
236  float f2 = static_cast<float>(p2);
237  // The significand precision for IEEE754 half precision is
238  // 11 bits (10 explicitly stored), or approximately 3 decimal
239  // digits. In selecting the fuzzy comparison factor of 102.5f
240  // (that is, (2^10+1)/10) below, we effectively select a
241  // window of about 1 (least significant) decimal digit about
242  // which the two operands can vary and still return true.
243  return (qAbs(f1 - f2) * 102.5f <= qMin(qAbs(f1), qAbs(f2)));
244 }
245 
249 [[nodiscard]] inline bool qFuzzyIsNull(qfloat16 f) noexcept
250 {
251  return qAbs(f) < 0.00976f; // 1/102.5 to 3 significant digits; see qFuzzyCompare()
252 }
253 
254 [[nodiscard]] inline bool qIsNull(qfloat16 f) noexcept
255 {
256  return (f.b16 & static_cast<quint16>(0x7fff)) == 0;
257 }
258 
259 inline int qIntCast(qfloat16 f) noexcept
260 { return int(static_cast<float>(f)); }
261 
262 #ifndef Q_QDOC
264 QT_WARNING_DISABLE_CLANG("-Wc99-extensions")
265 QT_WARNING_DISABLE_GCC("-Wold-style-cast")
266 inline qfloat16::qfloat16(float f) noexcept
267 {
268 #if defined(QT_COMPILER_SUPPORTS_F16C) && defined(__F16C__)
269  __m128 packsingle = _mm_set_ss(f);
270  __m128i packhalf = _mm_cvtps_ph(packsingle, 0);
271  b16 = _mm_extract_epi16(packhalf, 0);
272 #elif defined (__ARM_FP16_FORMAT_IEEE)
273  __fp16 f16 = __fp16(f);
274  memcpy(&b16, &f16, sizeof(quint16));
275 #else
276  quint32 u;
277  memcpy(&u, &f, sizeof(quint32));
278  const quint32 signAndExp = u >> 23;
279  const quint16 base = basetable[signAndExp];
280  const quint16 shift = shifttable[signAndExp];
281  const quint32 round = roundtable[signAndExp];
282  quint32 mantissa = (u & 0x007fffff);
283  if ((signAndExp & 0xff) == 0xff) {
284  if (mantissa) // keep nan from truncating to inf
285  mantissa = qMax(1U << shift, mantissa);
286  } else {
287  // round half to even
288  mantissa += round;
289  if (mantissa & (1 << shift))
290  --mantissa;
291  }
292 
293  // We use add as the mantissa may overflow causing
294  // the exp part to shift exactly one value.
295  b16 = quint16(base + (mantissa >> shift));
296 #endif
297 }
299 
300 inline qfloat16::operator float() const noexcept
301 {
302 #if defined(QT_COMPILER_SUPPORTS_F16C) && defined(__F16C__)
303  __m128i packhalf = _mm_cvtsi32_si128(b16);
304  __m128 packsingle = _mm_cvtph_ps(packhalf);
305  return _mm_cvtss_f32(packsingle);
306 #elif defined (__ARM_FP16_FORMAT_IEEE)
307  __fp16 f16;
308  memcpy(&f16, &b16, sizeof(quint16));
309  return float(f16);
310 #else
311  quint32 u = mantissatable[offsettable[b16 >> 10] + (b16 & 0x3ff)]
312  + exponenttable[b16 >> 10];
313  float f;
314  memcpy(&f, &u, sizeof(quint32));
315  return f;
316 #endif
317 }
318 #endif
319 
320 /*
321  qHypot compatibility; see ../kernel/qmath.h
322 */
323 namespace QtPrivate {
324 template <typename R>
325 struct QHypotType<R, qfloat16> { using type = decltype(std::hypot(R(1), 1.0f)); };
326 template <typename R>
327 struct QHypotType<qfloat16, R> { using type = decltype(std::hypot(1.0f, R(1))); };
328 template <> struct QHypotType<qfloat16, qfloat16> { using type = qfloat16; };
329 }
330 // Avoid passing qfloat16 to std::hypot(), while ensuring return types
331 // consistent with the above:
332 template<typename F, typename ...Fs> auto qHypot(F first, Fs... rest);
334 auto qHypot(T x, qfloat16 y) { return qHypot(x, float(y)); }
336 auto qHypot(qfloat16 x, T y) { return qHypot(float(x), y); }
337 template <> inline auto qHypot(qfloat16 x, qfloat16 y)
338 {
339 #if (defined(QT_COMPILER_SUPPORTS_F16C) && defined(__F16C__)) || defined (__ARM_FP16_FORMAT_IEEE)
340  return QtPrivate::QHypotHelper<qfloat16>(x).add(y).result();
341 #else
342  return qfloat16(qHypot(float(x), float(y)));
343 #endif
344 }
345 #if defined(__cpp_lib_hypot) && __cpp_lib_hypot >= 201603L // Expected to be true
346 // If any are not qfloat16, convert each qfloat16 to float:
347 /* (The following splits the some-but-not-all-qfloat16 cases up, using
348  (X|Y|Z)&~(X&Y&Z) = X ? ~(Y&Z) : Y|Z = X&~(Y&Z) | ~X&Y | ~X&~Y&Z,
349  into non-overlapping cases, to avoid ambiguity.) */
350 template <typename Ty, typename Tz,
351  typename std::enable_if<
352  // Ty, Tz aren't both qfloat16:
353  !(std::is_same_v<qfloat16, Ty> && std::is_same_v<qfloat16, Tz>), int>::type = 0>
354 auto qHypot(qfloat16 x, Ty y, Tz z) { return qHypot(float(x), y, z); }
355 template <typename Tx, typename Tz,
356  typename std::enable_if<
357  // Tx isn't qfloat16:
358  !std::is_same_v<qfloat16, Tx>, int>::type = 0>
359 auto qHypot(Tx x, qfloat16 y, Tz z) { return qHypot(x, float(y), z); }
360 template <typename Tx, typename Ty,
361  typename std::enable_if<
362  // Neither Tx nor Ty is qfloat16:
363  !std::is_same_v<qfloat16, Tx> && !std::is_same_v<qfloat16, Ty>, int>::type = 0>
364 auto qHypot(Tx x, Ty y, qfloat16 z) { return qHypot(x, y, float(z)); }
365 // If all are qfloat16, stay with qfloat16 (albeit via float, if no native support):
366 template <>
367 inline auto qHypot(qfloat16 x, qfloat16 y, qfloat16 z)
368 {
369 #if (defined(QT_COMPILER_SUPPORTS_F16C) && defined(__F16C__)) || defined (__ARM_FP16_FORMAT_IEEE)
370  return QtPrivate::QHypotHelper<qfloat16>(x).add(y).add(z).result();
371 #else
372  return qfloat16(qHypot(float(x), float(y), float(z)));
373 #endif
374 }
375 #endif // 3-arg std::hypot() is available
376 
378 
379 QT_DECL_METATYPE_EXTERN(qfloat16, Q_CORE_EXPORT)
380 
381 namespace std {
382 template<>
383 class numeric_limits<QT_PREPEND_NAMESPACE(qfloat16)> : public numeric_limits<float>
384 {
385 public:
386  /*
387  Treat quint16 b16 as if it were:
388  uint S: 1; // b16 >> 15 (sign); can be set for zero
389  uint E: 5; // (b16 >> 10) & 0x1f (offset exponent)
390  uint M: 10; // b16 & 0x3ff (adjusted mantissa)
391 
392  for E == 0: magnitude is M / 2.^{24}
393  for 0 < E < 31: magnitude is (1. + M / 2.^{10}) * 2.^{E - 15)
394  for E == 31: not finite
395  */
396  static constexpr int digits = 11;
397  static constexpr int min_exponent = -13;
398  static constexpr int max_exponent = 16;
399 
400  static constexpr int digits10 = 3;
401  static constexpr int max_digits10 = 5;
402  static constexpr int min_exponent10 = -4;
403  static constexpr int max_exponent10 = 4;
404 
406  { return QT_PREPEND_NAMESPACE(qfloat16)::_limit_epsilon(); }
407  static constexpr QT_PREPEND_NAMESPACE(qfloat16) (min)()
408  { return QT_PREPEND_NAMESPACE(qfloat16)::_limit_min(); }
409  static constexpr QT_PREPEND_NAMESPACE(qfloat16) denorm_min()
410  { return QT_PREPEND_NAMESPACE(qfloat16)::_limit_denorm_min(); }
411  static constexpr QT_PREPEND_NAMESPACE(qfloat16) (max)()
412  { return QT_PREPEND_NAMESPACE(qfloat16)::_limit_max(); }
413  static constexpr QT_PREPEND_NAMESPACE(qfloat16) lowest()
414  { return QT_PREPEND_NAMESPACE(qfloat16)::_limit_lowest(); }
415  static constexpr QT_PREPEND_NAMESPACE(qfloat16) infinity()
416  { return QT_PREPEND_NAMESPACE(qfloat16)::_limit_infinity(); }
417  static constexpr QT_PREPEND_NAMESPACE(qfloat16) quiet_NaN()
418  { return QT_PREPEND_NAMESPACE(qfloat16)::_limit_quiet_NaN(); }
419 #if QT_CONFIG(signaling_nan)
420  static constexpr QT_PREPEND_NAMESPACE(qfloat16) signaling_NaN()
421  { return QT_PREPEND_NAMESPACE(qfloat16)::_limit_signaling_NaN(); }
422 #else
423  static constexpr bool has_signaling_NaN = false;
424 #endif
425 };
426 
427 template<> class numeric_limits<const QT_PREPEND_NAMESPACE(qfloat16)>
428  : public numeric_limits<QT_PREPEND_NAMESPACE(qfloat16)> {};
429 template<> class numeric_limits<volatile QT_PREPEND_NAMESPACE(qfloat16)>
430  : public numeric_limits<QT_PREPEND_NAMESPACE(qfloat16)> {};
431 template<> class numeric_limits<const volatile QT_PREPEND_NAMESPACE(qfloat16)>
432  : public numeric_limits<QT_PREPEND_NAMESPACE(qfloat16)> {};
433 
434 // Adding overloads to std isn't allowed, so we can't extend this to support
435 // for fpclassify(), isnormal() &c. (which, furthermore, are macros on MinGW).
436 } // namespace std
437 
438 #endif // QFLOAT16_H
small capitals from c petite p scientific f u
Definition: afcover.h:88
Arabic default style
Definition: afstyles.h:94
#define value
[5]
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:66
bool qFuzzyCompare(const QMatrix4x4 &m1, const QMatrix4x4 &m2)
Definition: qmatrix4x4.cpp:774
auto add(F first, Fs... rest) const
Definition: qmath.h:155
Definition: base.h:37
Provides 16-bit floating point support.
Definition: qfloat16.h:75
constexpr qfloat16() noexcept
Definition: qfloat16.h:84
Q_CORE_EXPORT void qFloatFromFloat16(float *out, const qfloat16 *in, qsizetype len) noexcept
Definition: qfloat16.cpp:306
QT_WARNING_POP friend Q_CORE_EXPORT QDataStream & operator<<(QDataStream &ds, qfloat16 f)
Definition: qfloat16.cpp:327
constexpr bool isNormal() const noexcept
Definition: qfloat16.h:108
static constexpr qfloat16 _limit_quiet_NaN() noexcept
Definition: qfloat16.h:104
friend bool operator<(qfloat16 a, qfloat16 b) noexcept
Definition: qfloat16.h:171
friend bool operator!=(qfloat16 a, qfloat16 b) noexcept
Definition: qfloat16.h:175
static constexpr qfloat16 _limit_min() noexcept
Definition: qfloat16.h:99
bool isInf() const noexcept
Definition: qfloat16.h:90
friend bool operator>=(qfloat16 a, qfloat16 b) noexcept
Definition: qfloat16.h:172
friend bool operator==(qfloat16 a, qfloat16 b) noexcept
Definition: qfloat16.h:174
friend Q_CORE_EXPORT QDataStream & operator>>(QDataStream &ds, qfloat16 &f)
Definition: qfloat16.cpp:344
QT_WARNING_PUSH QT_WARNING_DISABLE_FLOAT_COMPARE friend bool operator>(qfloat16 a, qfloat16 b) noexcept
Definition: qfloat16.h:170
static constexpr qfloat16 _limit_infinity() noexcept
Definition: qfloat16.h:103
friend bool qIsNull(qfloat16 f) noexcept
Definition: qfloat16.h:254
static constexpr qfloat16 _limit_epsilon() noexcept
Definition: qfloat16.h:98
static constexpr qfloat16 _limit_denorm_min() noexcept
Definition: qfloat16.h:100
Q_CORE_EXPORT void qFloatToFloat16(qfloat16 *out, const float *in, qsizetype len) noexcept
Definition: qfloat16.cpp:287
bool isNaN() const noexcept
Definition: qfloat16.h:91
qfloat16(Qt::Initialization) noexcept
Definition: qfloat16.h:85
friend qfloat16 operator/(qfloat16 a, qfloat16 b) noexcept
Definition: qfloat16.h:133
friend bool operator<=(qfloat16 a, qfloat16 b) noexcept
Definition: qfloat16.h:173
friend qfloat16 operator-(qfloat16 a, qfloat16 b) noexcept
Definition: qfloat16.h:131
Q_CORE_EXPORT int fpClassify() const noexcept
Definition: qfloat16.cpp:165
bool isFinite() const noexcept
Definition: qfloat16.h:92
static constexpr qfloat16 _limit_lowest() noexcept
Definition: qfloat16.h:102
friend qfloat16 operator+(qfloat16 a, qfloat16 b) noexcept
Definition: qfloat16.h:130
friend qfloat16 operator*(qfloat16 a, qfloat16 b) noexcept
Definition: qfloat16.h:132
friend qfloat16 operator-(qfloat16 a) noexcept
Definition: qfloat16.h:123
qfloat16 copySign(qfloat16 sign) const noexcept
Definition: qfloat16.h:95
static constexpr qfloat16 _limit_max() noexcept
Definition: qfloat16.h:101
static constexpr QT_PREPEND_NAMESPACE(qfloat16) lowest()
Definition: qfloat16.h:413
static constexpr QT_PREPEND_NAMESPACE(qfloat16) epsilon()
Definition: qfloat16.h:405
static constexpr QT_PREPEND_NAMESPACE(qfloat16) infinity()
Definition: qfloat16.h:415
static constexpr QT_PREPEND_NAMESPACE(qfloat16) quiet_NaN()
Definition: qfloat16.h:417
static constexpr QT_PREPEND_NAMESPACE(qfloat16) denorm_min()
Definition: qfloat16.h:409
QPixmap p2
QPixmap p1
[0]
uint32_t shifttable[512]
uint32_t basetable[512]
uint32_t roundtable[512]
auto it unsigned count const
Definition: hb-iter.hh:848
#define inline
Definition: md4c.c:45
#define F(x, y, z)
Definition: md5.c:51
Initialization
Definition: qnamespace.h:1610
Definition: qfloat16.h:381
#define QT_WARNING_POP
#define QT_WARNING_DISABLE_FLOAT_COMPARE
#define QT_WARNING_DISABLE_GCC(text)
#define QT_WARNING_PUSH
#define QT_WARNING_DISABLE_CLANG(text)
EGLOutputLayerEXT EGLint EGLAttrib value
#define QF16_MAKE_ARITH_OP_INT(OP)
Definition: qfloat16.h:157
bool qIsFinite(qfloat16 f) noexcept
Definition: qfloat16.h:222
#define QF16_MAKE_ARITH_OP(FP)
Definition: qfloat16.h:141
#define QF16_MAKE_BOOL_OP(FP)
Definition: qfloat16.h:180
bool qFuzzyIsNull(qfloat16 f) noexcept
Definition: qfloat16.h:249
bool qIsNaN(qfloat16 f) noexcept
Definition: qfloat16.h:221
int qFpClassify(qfloat16 f) noexcept
Definition: qfloat16.h:223
#define QF16_MAKE_BOOL_OP_INT(OP)
Definition: qfloat16.h:194
bool qIsInf(qfloat16 f) noexcept
Definition: qfloat16.h:220
Q_DECLARE_TYPEINFO(qfloat16, Q_PRIMITIVE_TYPE)
bool qIsNull(qfloat16 f) noexcept
Definition: qfloat16.h:254
qint64 qRound64(qfloat16 d) noexcept
Definition: qfloat16.h:230
int qRound(qfloat16 d) noexcept
Definition: qfloat16.h:227
int qIntCast(qfloat16 f) noexcept
Definition: qfloat16.h:259
auto qHypot(F first, Fs... rest)
Definition: qmath.h:181
unsigned int quint32
Definition: qglobal.h:288
unsigned short quint16
Definition: qglobal.h:286
ptrdiff_t qsizetype
Definition: qglobal.h:308
long long qint64
Definition: qglobal.h:298
bool int shift
#define QT_DECL_METATYPE_EXTERN(TYPE, EXPORT)
Definition: qmetatype.h:1285
GLenum GLuint GLenum GLsizei length
Definition: qopengl.h:270
GLenum type
Definition: qopengl.h:270
GLboolean GLboolean GLboolean b
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat z
GLint GLint GLint GLint GLint x
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLfloat GLfloat f
GLint first
GLint y
QPointF qAbs(const QPointF &p)
Definition: qscroller.cpp:119
int QT_PREPEND_NAMESPACE(QSharedMemoryPrivate)
@ Q_PRIMITIVE_TYPE
Definition: qtypeinfo.h:155
decltype(std::hypot(R(1), 1.0f)) type
Definition: qfloat16.h:325
decltype(std::hypot(1.0f, R(1))) type
Definition: qfloat16.h:327
Definition: main.cpp:38
const qreal epsilon
Definition: tst_qline.cpp:63