summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
authorGlen Mabey <Glen.Mabey@swri.org>2013-06-22 19:43:46 -0500
committerGlen Mabey <Glen.Mabey@swri.org>2017-01-31 14:21:42 +0000
commit3ab7016632c825949f32b72d06ac324b6672b9f6 (patch)
treea385f0389c9b0f37e8c2e4f19980392d16c0b409 /src/corelib/io
parente5d303cb9fb3ade3fae6d3f14a5f4fe139af63c9 (diff)
New qfloat16 class
This constitutes a fairly complete submission of an entirely new floating point type which conforms to IEEE 754 as a 16-bit storage class. Conversion between qfloat16 and float is currently performed through a sequence of lookup tables. Global-level functions qRound(), qRound64(), qFuzzyCompare(), qFuzzyIsNull(), and qIsNull() each with a qfloat16 parameter have been included for completeness. [ChangeLog][QtCore] Added new qfloat16 class. Change-Id: Ia52eb27846965c14f8140c00faf5ba33c9443976 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qdatastream.cpp23
-rw-r--r--src/corelib/io/qdatastream.h9
2 files changed, 31 insertions, 1 deletions
diff --git a/src/corelib/io/qdatastream.cpp b/src/corelib/io/qdatastream.cpp
index 2730fd7f11..cac5152e87 100644
--- a/src/corelib/io/qdatastream.cpp
+++ b/src/corelib/io/qdatastream.cpp
@@ -448,6 +448,9 @@ QDataStream::FloatingPointPrecision QDataStream::floatingPointPrecision() const
The default is DoublePrecision.
+ Note that this property does not affect the serialization or deserialization of \c qfloat16
+ instances.
+
\warning This property must be set to the same value on the object that writes and the object
that reads the data stream.
@@ -972,6 +975,16 @@ QDataStream &QDataStream::operator>>(double &f)
/*!
+ \fn QDataStream &QDataStream::operator>>(qfloat16 &f)
+ \overload
+ \since 5.9
+
+ Reads a floating point number from the stream into \a f,
+ using the standard IEEE 754 format. Returns a reference to the
+ stream.
+*/
+
+/*!
\overload
Reads the '\\0'-terminated string \a s from the stream and returns
@@ -1260,6 +1273,15 @@ QDataStream &QDataStream::operator<<(double f)
/*!
+ \fn QDataStream &QDataStream::operator<<(qfloat16 f)
+ \overload
+ \since 5.9
+
+ Writes a floating point number, \a f, to the stream using
+ the standard IEEE 754 format. Returns a reference to the stream.
+*/
+
+/*!
\overload
Writes the '\\0'-terminated string \a s to the stream and returns a
@@ -1282,7 +1304,6 @@ QDataStream &QDataStream::operator<<(const char *s)
return *this;
}
-
/*!
Writes the length specifier \a len and the buffer \a s to the
stream and returns a reference to the stream.
diff --git a/src/corelib/io/qdatastream.h b/src/corelib/io/qdatastream.h
index 994ed88791..9a7d7e275d 100644
--- a/src/corelib/io/qdatastream.h
+++ b/src/corelib/io/qdatastream.h
@@ -43,6 +43,7 @@
#include <QtCore/qscopedpointer.h>
#include <QtCore/qiodevice.h>
#include <QtCore/qpair.h>
+#include <QtCore/qfloat16.h>
#ifdef Status
#error qdatastream.h must be included before any header file that defines Status
@@ -154,6 +155,7 @@ public:
QDataStream &operator>>(quint64 &i);
QDataStream &operator>>(bool &i);
+ QDataStream &operator>>(qfloat16 &f);
QDataStream &operator>>(float &f);
QDataStream &operator>>(double &f);
QDataStream &operator>>(char *&str);
@@ -167,6 +169,7 @@ public:
QDataStream &operator<<(qint64 i);
QDataStream &operator<<(quint64 i);
QDataStream &operator<<(bool i);
+ QDataStream &operator<<(qfloat16 f);
QDataStream &operator<<(float f);
QDataStream &operator<<(double f);
QDataStream &operator<<(const char *str);
@@ -345,6 +348,9 @@ inline QDataStream &QDataStream::operator>>(quint32 &i)
inline QDataStream &QDataStream::operator>>(quint64 &i)
{ return *this >> reinterpret_cast<qint64&>(i); }
+inline QDataStream &QDataStream::operator>>(qfloat16 &f)
+{ return *this >> reinterpret_cast<qint16&>(f); }
+
inline QDataStream &QDataStream::operator<<(quint8 i)
{ return *this << qint8(i); }
@@ -357,6 +363,9 @@ inline QDataStream &QDataStream::operator<<(quint32 i)
inline QDataStream &QDataStream::operator<<(quint64 i)
{ return *this << qint64(i); }
+inline QDataStream &QDataStream::operator<<(qfloat16 f)
+{ return *this << reinterpret_cast<qint16&>(f); }
+
template <typename T>
inline QDataStream &operator>>(QDataStream &s, QList<T> &l)
{