[ast] fix string() regression after 97488f67 07/21207/2
St├ęphane MOTTELET [Mon, 6 Jan 2020 13:20:19 +0000 (14:20 +0100)]
Change-Id: I3ca07f22c9b922bdbbb467fec3fd16f2714a3364

scilab/modules/ast/src/cpp/types/tostring_common.cpp

index e8bbc6c..e1a222e 100644 (file)
@@ -294,17 +294,14 @@ void addDoubleValue(std::wostringstream * _postr, double _dblVal, DoubleFormat *
             iWidth--;
         }
 
-        // append trailing zeros, if applicable
-        if (std::atof(str.data()) != fabs(_dblVal) && _pDF->bPrintTrailingZeros == true)
+        // trim or append trailing zeros, if applicable
+        if (_pDF->bPrintPoint == false)
         {
-            if (_pDF->bPrintPoint)
-            {
-                str.append(std::max(0, (ConfigVariable::getFormatSize() - (int)str.length()))-1, '0');
-            }
-            else
-            {
-                iWidth = 1+str.length();
-            }
+            iWidth = 1+str.length();
+        }
+        else if (std::atof(str.data()) != fabs(_dblVal) && _pDF->bPrintTrailingZeros == true)
+        {
+            str.append(std::max(0, (ConfigVariable::getFormatSize() - (int)str.length()))-1, '0');
         }
 
         wchar_t* pwstData = to_wide_string(str.data());