From 655a1730fe2a77c7ce04cd8e36832bf3bd394919 Mon Sep 17 00:00:00 2001 From: James Larcombe Date: Tue, 20 Apr 2010 12:54:06 +0100 Subject: [PATCH] Reorganised double stream out operator in QDataStream to avoid causing unnecessary floating point exceptions. --- src/corelib/io/qdatastream.cpp | 7 ++++--- 1 files 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; -- 1.7.0.2.msysgit.0