diff options
author | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2015-11-09 11:48:39 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2015-11-24 14:01:08 +0000 |
commit | 4c2dd1a9c1559b4f925a907a832580867dda91e5 (patch) | |
tree | 86904086b27df70f584443e03a3611d9ee24a1b7 /src/corelib/tools/qlocale.cpp | |
parent | 5c8c4d0b2127a5110e05fa4afa1b8883cc91a5df (diff) |
Centralize dropping of trailing zeroes when converting doubles
We're never interested in trailing zeroes, unless the number is exactly
0. qdtoa would return an empty string if the result was exactly '0',
which is also fixed by this change.
Change-Id: I3ba2f7e835b92d54d9008ad03fdf6ce5fb3af8a4
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'src/corelib/tools/qlocale.cpp')
-rw-r--r-- | src/corelib/tools/qlocale.cpp | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index c91d267772..1f4d0c88c5 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -2757,12 +2757,7 @@ QString QLocaleData::doubleToString(const QChar _zero, const QChar plus, const Q if (qstrncmp(buf.data(), "inf", 3) == 0 || qstrncmp(buf.data(), "nan", 3) == 0) { num_str = QString::fromLatin1(buf.data(), length); } else { // Handle normal numbers - - // Chop trailing zeros - int last_nonzero_idx = length - 1; - while (last_nonzero_idx > 0 && buf[last_nonzero_idx] == '0') - --last_nonzero_idx; - QString digits = QString::fromLatin1(buf.data(), last_nonzero_idx + 1); + QString digits = QString::fromLatin1(buf.data(), length); if (_zero.unicode() != '0') { ushort z = _zero.unicode() - '0'; |