fix bug 1371 : display size of double takes into account the size of power 80/15680/4
Sylvain GENIN [Tue, 9 Dec 2014 16:05:22 +0000 (17:05 +0100)]
test_run("output_stream","bug_1371",["no_check_error_output" ]);

Change-Id: I977d3d4ed509bcf0fb78fcb50dd47d5a9646ea77

scilab/modules/ast/src/cpp/types/tostring_common.cpp
scilab/modules/output_stream/tests/nonreg_tests/bug_1371.dia.ref
scilab/modules/output_stream/tests/nonreg_tests/bug_1371.tst

index fad3f38..09376e0 100644 (file)
@@ -108,7 +108,7 @@ void getDoubleFormat(double _dblVal, DoubleFormat * _pDF)
         {
             //exponant
             _pDF->bExp = true;
-            iTotalLen = iBlankSize + 1 /*integer before dot */  + POINT_SIZE + EXPOSANT_SIZE + std::max((int)log10((double)iNbDigit), 2);
+            iTotalLen = iBlankSize + 1 /*integer before dot */  + POINT_SIZE + EXPOSANT_SIZE + std::max(((int)log10((double)iNbDigit)) + 1, 2);
             _pDF->iWidth = iPrecNeeded;
             _pDF->iPrec = iPrecNeeded - iTotalLen;
             return;
@@ -131,7 +131,7 @@ void getDoubleFormat(double _dblVal, DoubleFormat * _pDF)
             }
 
             _pDF->bExp = true;
-            iTotalLen = iBlankSize + 1 /*integer before dot */  + POINT_SIZE + EXPOSANT_SIZE + std::max((int)log10(dblTemp), 2);
+            iTotalLen = iBlankSize + 1 /*integer before dot */  + POINT_SIZE + EXPOSANT_SIZE + std::max(((int)log10(dblTemp)) + 1, 2);
             _pDF->iWidth = iPrecNeeded;
             _pDF->iPrec = iPrecNeeded - iTotalLen;
             return;
index f8cc715..6b339bb 100644 (file)
@@ -22,8 +22,8 @@ if string(1.2345d-123)<>"1.23D-123" then bugmes();quit;end
 if string(-1.78945d-88)<>"-1.789D-88"  then bugmes();quit;end
 if string(-1.2345d-123)<>"-1.23D-123" then bugmes();quit;end
 format(10,"v")
-if string(1.78945d88+%i)<>" 1.789D+88+%i"  then bugmes();quit;end
-if string(1.2345d123+%i)<>" 1.23D+123+%i" then bugmes();quit;end
+if string(1.78945d88+%i)<>"1.789D+88+%i"  then bugmes();quit;end
+if string(1.2345d123+%i)<>"1.23D+123+%i" then bugmes();quit;end
 if string(-1.78945d88-%i)<>"-1.789D+88-%i"  then bugmes();quit;end
 if string(-1.2345d123+3.33*%i)<>"-1.23D+123+%i*3.33" then bugmes();quit;end
 if string(1.2345d-123*%i)<>"%i*1.23D-123" then bugmes();quit;end
@@ -39,9 +39,9 @@ if string(-1.2345678d-123)<>"-1.2345678D-123" then bugmes();quit;end
 format(10,"v")
 A=[1.7894567d120  1.2345678d123
    4.2345678d123 -7.7894567d120];
-if or(string(A)<>["1.78D+120","1.23D+123";"4.23D+123","-7.78D+120"]) then bugmes();quit;end
+if or(string(A)<>["1.79D+120","1.23D+123";"4.23D+123","-7.79D+120"]) then bugmes();quit;end
 A=[1.7894567d120+%i  1.2345678*%i
    4.2345678d123 -7.7894567d120-2.45*%i];
-if or(string(A)<> [" 1.78D+120+%i","%i*1.2345678";" 4.23D+123","-7.78D+120-%i*2.45"]) then bugmes();quit;end
+if or(string(A)<> ["1.79D+120+%i","%i*1.2345678";"4.23D+123","-7.79D+120-%i*2.45"]) then bugmes();quit;end
 P=1.2345678d-123-1.7894567d88*%s;
 if or(string(P)<>["                      ";"1.23D-123 - 1.789D+88s"] ) then bugmes();quit;end
index 1d2ceeb..6105a28 100644 (file)
@@ -27,8 +27,8 @@ if string(-1.78945d-88)<>"-1.789D-88"  then pause,end
 if string(-1.2345d-123)<>"-1.23D-123" then pause,end
 
 format(10,"v")
-if string(1.78945d88+%i)<>" 1.789D+88+%i"  then pause,end
-if string(1.2345d123+%i)<>" 1.23D+123+%i" then pause,end
+if string(1.78945d88+%i)<>"1.789D+88+%i"  then pause,end
+if string(1.2345d123+%i)<>"1.23D+123+%i" then pause,end
 if string(-1.78945d88-%i)<>"-1.789D+88-%i"  then pause,end
 if string(-1.2345d123+3.33*%i)<>"-1.23D+123+%i*3.33" then pause,end
 if string(1.2345d-123*%i)<>"%i*1.23D-123" then pause,end
@@ -57,13 +57,13 @@ if string(-1.2345678d-123)<>"-1.2345678D-123" then pause,end
 format(10,"v")
 
 A=[1.7894567d120  1.2345678d123
-   4.2345678d123 -7.7894567d120];
-if or(string(A)<>["1.78D+120","1.23D+123";"4.23D+123","-7.78D+120"]) then pause,end
+4.2345678d123 -7.7894567d120];
+if or(string(A)<>["1.79D+120","1.23D+123";"4.23D+123","-7.79D+120"]) then pause,end
 
 
 A=[1.7894567d120+%i  1.2345678*%i
-   4.2345678d123 -7.7894567d120-2.45*%i];
-if or(string(A)<> [" 1.78D+120+%i","%i*1.2345678";" 4.23D+123","-7.78D+120-%i*2.45"]) then pause,end
+4.2345678d123 -7.7894567d120-2.45*%i];
+if or(string(A)<> ["1.79D+120+%i","%i*1.2345678";"4.23D+123","-7.79D+120-%i*2.45"]) then pause,end
 
 
 P=1.2345678d-123-1.7894567d88*%s;