diff options
author | James Larcombe <jlarcombe@sibelius.com> | 2010-04-20 11:54:06 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2010-04-21 07:33:34 (GMT) |
commit | c9a5b8f0d840e67ad33839c8c310aef73a8a855c (patch) | |
tree | 7903f3cde2a09536aad94e6f976c81838870310d /src/corelib/io/qdatastream.cpp | |
parent | 4c4f726a91e9177ad6840c80a347f73932eda844 (diff) | |
download | Qt-c9a5b8f0d840e67ad33839c8c310aef73a8a855c.zip Qt-c9a5b8f0d840e67ad33839c8c310aef73a8a855c.tar.gz Qt-c9a5b8f0d840e67ad33839c8c310aef73a8a855c.tar.bz2 |
Reorganised double stream out operator in QDataStream to avoid causing unnecessary floating point exceptions.
Signed-off-by: Thiago Macieira <thiago.macieira@nokia.com>
Diffstat (limited to 'src/corelib/io/qdatastream.cpp')
-rw-r--r-- | 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; |