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 <thiago.macieira@intel.com>
This commit is contained in:
Edward Welbourne 2019-09-17 19:55:44 +02:00
parent 7bf4f81de8
commit 3c7df4a0ff

View File

@ -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<const QT_PREPEND_NAMESPACE(qfloat16)>