Provides 16-bit floating point support.
The
qfloat16
class provides support for half-precision (16-bit) floating point data. It is fully compliant with IEEE 754 as a storage type. This implies that any arithmetic operation on aqfloat16
instance results in the value first being converted to afloat
. This conversion to and fromfloat
is performed by hardware when possible, but on processors that do not natively support half-precision, the conversion is performed through a sequence of lookup table operations.
qfloat16
should be treated as if it were a POD (plain old data) type. Consequently, none of the supported operations need any elaboration beyond stating that it supports all arithmetic operators incident to floating point types.Note
On x86 and x86-64 that to get hardware accelerated conversions you must compile with F16C or AVX2 enabled, or use
qFloatToFloat16()
andqFloatFromFloat16()
which will detect F16C at runtime.Defining this macro disables the arithmetic operators for qfloat16.
This is only necessary on Visual Studio 2017 (and earlier) when including
<QFloat16>
and<bitset>
in the same translation unit, which would otherwise cause a compilation error due to a toolchain bug (see [QTBUG-72073]).Returns a qfloat16 with the sign of
sign
but the rest of its value taken from this qfloat16. Serves as qfloat16’s equivalent of std::copysign().Implements
qFpClassify()
for qfloat16.See also
qFpClassify()
Returns
true
if thisqfloat16
value is finite and in normal form.See also
qFpClassify()
Converts
len
qfloat16 fromin
to floats and stores them inout
. Bothin
andout
must havelen
allocated entries.This function is faster than converting values one by one, and will do runtime F16C detection on x86 and x86-64 hardware.
Converts
len
floats fromin
to qfloat16 and stores them inout
. Bothin
andout
must havelen
allocated entries.This function is faster than converting values one by one, and will do runtime F16C detection on x86 and x86-64 hardware.
Compares the floating point value
p1
andp2
and returnstrue
if they are considered equal, otherwisefalse
.The two numbers are compared in a relative way, where the exactness is stronger the smaller the numbers are.
Returns true if the
qfloat16
f
is a finite number.See also
qIsFinite
Returns true if the
qfloat16
f
is equivalent to infinity.See also
qIsInf
Returns true if the
qfloat16
f
is not a number (NaN).See also
qIsNaN
Rounds
value
to the nearest integer.See also
qRound
Rounds
value
to the nearest 64-bit integer.See also
qRound64
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.