diff --git a/src/Internat.cpp b/src/Internat.cpp index 9e1455c98..911e106f1 100644 --- a/src/Internat.cpp +++ b/src/Internat.cpp @@ -89,7 +89,7 @@ wxString Internat::ToString(double numberToConvert, } wxString Internat::ToDisplayString(double numberToConvert, - int digitsAfterDecimalPoint /* = -1 */) + int digitsAfterDecimalPoint /* = -1 */) { wxString decSep = wxString(GetDecimalSeparator()); wxString result; @@ -99,20 +99,24 @@ wxString Internat::ToDisplayString(double numberToConvert, result.Printf(wxT("%f"), numberToConvert); // Not all libcs respect the decimal separator, so always convert - // any dots found to the decimal separator + // any dots found to the decimal separator. result.Replace(wxT("."), decSep); if (result.Find(decSep) != -1) { - // Strip trailing zeros + // Strip trailing zeros, but leave one, and decimal separator. int pos = result.Length() - 1; - while (pos > 0 && result.GetChar(pos) == wxT('0')) + while ((pos > 1) && + (result.GetChar(pos) == wxT('0')) && + (result.GetChar(pos - 1) != decSep)) pos--; - if (result.GetChar(pos) == decSep) - pos--; // strip point before empty fractional part + // (Previous code removed all of them and decimal separator.) + // if (result.GetChar(pos) == decSep) + // pos--; // strip point before empty fractional part result = result.Left(pos+1); } - } else + } + else { wxString format; format.Printf(wxT("%%.%if"), digitsAfterDecimalPoint);