From 3c7df4a0ff91a833cf77e38ab8ccd65e289242e9 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 17 Sep 2019 19:55:44 +0200 Subject: [PATCH] Add support for a signaling NaN in qfloat16 There was a comment saying what value does the job, so might as well put it to work. Change-Id: I47f1a8ce7ce889580f71aa784ccbcc227ebe0b23 Reviewed-by: Thiago Macieira --- src/corelib/global/qfloat16.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/corelib/global/qfloat16.h b/src/corelib/global/qfloat16.h index c50fa36402..154b200475 100644 --- a/src/corelib/global/qfloat16.h +++ b/src/corelib/global/qfloat16.h @@ -95,7 +95,9 @@ public: static constexpr qfloat16 _limit_lowest() noexcept { return qfloat16(Wrap(0xfbff)); } static constexpr qfloat16 _limit_infinity() noexcept { return qfloat16(Wrap(0x7c00)); } static constexpr qfloat16 _limit_quiet_NaN() noexcept { return qfloat16(Wrap(0x7e00)); } - // Signalling NaN is 0x7f00 +#if QT_CONFIG(signaling_nan) + static constexpr qfloat16 _limit_signaling_NaN() noexcept { return qfloat16(Wrap(0x7f00)); } +#endif inline constexpr bool isNormal() const noexcept { return (b16 & 0x7fff) == 0 || ((b16 & 0x7c00) && (b16 & 0x7c00) != 0x7c00); } private: @@ -330,6 +332,12 @@ public: { return QT_PREPEND_NAMESPACE(qfloat16)::_limit_infinity(); } static constexpr QT_PREPEND_NAMESPACE(qfloat16) quiet_NaN() { return QT_PREPEND_NAMESPACE(qfloat16)::_limit_quiet_NaN(); } +#if QT_CONFIG(signaling_nan) + static constexpr QT_PREPEND_NAMESPACE(qfloat16) signaling_NaN() + { return QT_PREPEND_NAMESPACE(qfloat16)::_limit_signaling_NaN(); } +#else + static constexpr bool has_signaling_NaN = false; +#endif }; template<> class numeric_limits