From c9a5b8f0d840e67ad33839c8c310aef73a8a855c Mon Sep 17 00:00:00 2001 From: James Larcombe Date: Tue, 20 Apr 2010 12:54:06 +0100 Subject: Reorganised double stream out operator in QDataStream to avoid causing unnecessary floating point exceptions. Signed-off-by: Thiago Macieira --- src/corelib/io/qdatastream.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/corelib/io/qdatastream.cpp b/src/corelib/io/qdatastream.cpp index 2731ae1..3a9d284 100644 --- a/src/corelib/io/qdatastream.cpp +++ b/src/corelib/io/qdatastream.cpp @@ -1144,16 +1144,17 @@ QDataStream &QDataStream::operator<<(double f) CHECK_STREAM_PRECOND(*this) #ifndef Q_DOUBLE_FORMAT - if (!noswap) { + if (noswap) { + dev->write((char *)&f, sizeof(double)); + } else { union { double val1; quint64 val2; } x; x.val1 = f; x.val2 = qbswap(x.val2); - f = x.val1; + dev->write((char *)&x.val2, sizeof(double)); } - dev->write((char *)&f, sizeof(double)); #else union { double val1; -- cgit v0.12