From 1261f391cccfb73c6aa087594c03e0ea37c30793 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Thu, 15 Oct 2020 00:47:53 +0200 Subject: [PATCH] Floating point function helpers: code tidies Change-Id: Id87390734f4ccb28fb83d25788ca600747c2e2a8 Reviewed-by: Lars Knoll --- src/corelib/global/qglobal.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 7800b0e2c6..555cde4e6a 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -909,22 +909,22 @@ typedef void (*QFunctionPointer)(); # define Q_UNIMPLEMENTED() qWarning("Unimplemented code.") #endif -[[nodiscard]] [[maybe_unused]] constexpr static inline bool qFuzzyCompare(double p1, double p2) +[[nodiscard]] constexpr bool qFuzzyCompare(double p1, double p2) { return (qAbs(p1 - p2) * 1000000000000. <= qMin(qAbs(p1), qAbs(p2))); } -[[nodiscard]] [[maybe_unused]] constexpr static inline bool qFuzzyCompare(float p1, float p2) +[[nodiscard]] constexpr bool qFuzzyCompare(float p1, float p2) { return (qAbs(p1 - p2) * 100000.f <= qMin(qAbs(p1), qAbs(p2))); } -[[nodiscard]] [[maybe_unused]] constexpr static inline bool qFuzzyIsNull(double d) +[[nodiscard]] constexpr bool qFuzzyIsNull(double d) { return qAbs(d) <= 0.000000000001; } -[[nodiscard]] [[maybe_unused]] constexpr static inline bool qFuzzyIsNull(float f) +[[nodiscard]] constexpr bool qFuzzyIsNull(float f) { return qAbs(f) <= 0.00001f; } @@ -932,12 +932,12 @@ typedef void (*QFunctionPointer)(); QT_WARNING_PUSH QT_WARNING_DISABLE_FLOAT_COMPARE -[[nodiscard]] [[maybe_unused]] constexpr static inline bool qIsNull(double d) noexcept +[[nodiscard]] constexpr bool qIsNull(double d) noexcept { return d == 0.0; } -[[nodiscard]] [[maybe_unused]] constexpr static inline bool qIsNull(float f) noexcept +[[nodiscard]] constexpr bool qIsNull(float f) noexcept { return f == 0.0f; }