diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2020-04-15 18:31:51 +0200 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2021-04-29 14:13:23 +0200 |
commit | 6dfec83051c3426fcf2336f8b7acfdc290efe94c (patch) | |
tree | b6b9ab31164a48035024df1b01d498de20887003 /src/corelib/global/qfloat16.h | |
parent | 16c96837182056a1a755e420289dce8a57341c6c (diff) |
Add tests for qFuzzyIsNull() to tst_QNumeric and tst_QFloat16
They were missing.
I also wanted to verify that it's true for sub-normal values.
At the same time, relocate qfloat16's implementation of qFuzzyIsNull()
to between those of qFuzzyCompare() and qIsNull(), since its apparent
absence initially confused me.
Change-Id: I9637c0070e754d16744c76fc9f846596257c6a63
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/global/qfloat16.h')
-rw-r--r-- | src/corelib/global/qfloat16.h | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/corelib/global/qfloat16.h b/src/corelib/global/qfloat16.h index 387735863e..e574ffed78 100644 --- a/src/corelib/global/qfloat16.h +++ b/src/corelib/global/qfloat16.h @@ -234,6 +234,14 @@ Q_CORE_EXPORT void qFloatFromFloat16(float *, const qfloat16 *, qsizetype length return (qAbs(f1 - f2) * 102.5f <= qMin(qAbs(f1), qAbs(f2))); } +/*! + \internal +*/ +[[nodiscard]] inline bool qFuzzyIsNull(qfloat16 f) noexcept +{ + return qAbs(static_cast<float>(f)) <= 0.001f; +} + [[nodiscard]] inline bool qIsNull(qfloat16 f) noexcept { return (f.b16 & static_cast<quint16>(0x7fff)) == 0; @@ -300,14 +308,6 @@ inline qfloat16::operator float() const noexcept } #endif -/*! - \internal -*/ -[[nodiscard]] inline bool qFuzzyIsNull(qfloat16 f) noexcept -{ - return qAbs(static_cast<float>(f)) <= 0.001f; -} - /* qHypot compatibility; see ../kernel/qmath.h */ |