diff options
-rw-r--r-- | src/corelib/tools/qlocale.cpp | 7 | ||||
-rw-r--r-- | src/corelib/tools/qlocale_tools.cpp | 6 |
2 files changed, 3 insertions, 10 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'; diff --git a/src/corelib/tools/qlocale_tools.cpp b/src/corelib/tools/qlocale_tools.cpp index cdc654904e..f766a301c5 100644 --- a/src/corelib/tools/qlocale_tools.cpp +++ b/src/corelib/tools/qlocale_tools.cpp @@ -267,6 +267,8 @@ void doubleToAscii(double d, QLocaleData::DoubleForm form, int precision, char * } } #endif // QT_NO_DOUBLECONVERSION || QT_BOOTSTRAPPED + while (length > 1 && buf[length - 1] == '0') // drop trailing zeroes + --length; } double asciiToDouble(const char *num, int numLen, bool &ok, int &processed) @@ -546,10 +548,6 @@ QString qdtoa(qreal d, int *decpt, int *sign) doubleToAscii(d, QLocaleData::DFSignificantDigits, QLocale::FloatingPointShortest, result, QLocaleData::DoubleMaxSignificant + 1, nonNullSign, length, nonNullDecpt); - // Skip trailing zeroes. The DoubleMaxSignificant precision is the worst case. - while (length > 0 && result[length - 1] == '0') - --length; - if (sign) *sign = nonNullSign ? 1 : 0; if (decpt) |