diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2019-03-22 16:03:59 +0100 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2019-04-24 13:08:52 +0000 |
commit | 934000c11afe8b03c81a8f52f3a51be6615087c6 (patch) | |
tree | ad57b5cd54207e5222b0f4fb19975176b64683d5 /src/corelib/global/qfloat16.cpp | |
parent | 2eb849ed516afc8e602dbec3da0ac12db2cdf8ec (diff) |
Implement qFpClassify(qfloat16)
This extends support for qfloat16 sufficiently for the things testlib
needs in order to treat it as a first-class citizen. Extended tests
for qfloat to check qFpClassify() on it.
Change-Id: I906292afaf51cd9c94ba384ff5aaa855edd56da1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/global/qfloat16.cpp')
-rw-r--r-- | src/corelib/global/qfloat16.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/corelib/global/qfloat16.cpp b/src/corelib/global/qfloat16.cpp index 680268c59b..2bf6ff00c2 100644 --- a/src/corelib/global/qfloat16.cpp +++ b/src/corelib/global/qfloat16.cpp @@ -1,5 +1,6 @@ /**************************************************************************** ** +** Copyright (C) 2019 The Qt Company Ltd. ** Copyright (C) 2016 by Southwest Research Institute (R) ** Contact: http://www.qt-project.org/legal ** @@ -39,6 +40,7 @@ #include "qfloat16.h" #include "private/qsimd_p.h" +#include <cmath> // for fpclassify()'s return values QT_BEGIN_NAMESPACE @@ -91,6 +93,17 @@ QT_BEGIN_NAMESPACE \sa qIsFinite */ +/*! + \internal + Implements qFpClassify() for qfloat16. + */ + +int qfloat16::fpClassify() const noexcept +{ + return isInf() ? FP_INFINITE : isNaN() ? FP_NAN + : !b16 ? FP_ZERO : isNormal() ? FP_NORMAL : FP_SUBNORMAL; +} + /*! \fn int qRound(qfloat16 value) \relates <QFloat16> |