--- src/corelib/tools/qlocale.cpp
+++ src/corelib/tools/qlocale.cpp
@@ -2753,7 +2753,9 @@ QString QLocaleData::doubleToString(const QChar _zero, const QChar plus, const Q
int decpt;
int bufSize = 1;
- if (form == DFDecimal) // optimize for numbers smaller than 512k
+ if (precision == QLocale::FloatingPointShortest)
+ bufSize += DoubleMaxSignificant;
+ else if (form == DFDecimal) // optimize for numbers between -512k and 512k
bufSize += ((d > (1 << 19) || d < -(1 << 19)) ? DoubleMaxDigitsBeforeDecimal : 6) +
precision;
else // Add extra digit due to different interpretations of precision. Also, "nan" has to fit.