diff --git a/src/corelib/global/qfloat16.h b/src/corelib/global/qfloat16.h index e574ffed78..c2e5379eb4 100644 --- a/src/corelib/global/qfloat16.h +++ b/src/corelib/global/qfloat16.h @@ -239,7 +239,7 @@ Q_CORE_EXPORT void qFloatFromFloat16(float *, const qfloat16 *, qsizetype length */ [[nodiscard]] inline bool qFuzzyIsNull(qfloat16 f) noexcept { - return qAbs(static_cast(f)) <= 0.001f; + return qAbs(f) < 0.00976f; // 1/102.5 to 3 significant digits; see qFuzzyCompare() } [[nodiscard]] inline bool qIsNull(qfloat16 f) noexcept diff --git a/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp index 71a05d3031..35d7dbccf0 100644 --- a/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp +++ b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp @@ -118,7 +118,7 @@ void tst_qfloat16::fuzzyIsNull_data() QTest::addColumn("value"); QTest::addColumn("isNull"); using Bounds = std::numeric_limits; - const qfloat16 one(1), huge(1000), tiny(0.00099f); + const qfloat16 one(1), huge(1000), tiny(0.00976f); QTest::newRow("zero") << qfloat16(0.0f) << true; QTest::newRow("min") << Bounds::min() << true;