diff libinterp/interpfcn/pr-output.cc @ 16339:0c340bf413d7

allow exponent in output to always have 3 digits * pr-output.cc (set_real_format): Always allow 3 digits for exponent. Increase field width by 1 for engineering and scientific formats.
author John W. Eaton <jwe@octave.org>
date Tue, 19 Mar 2013 20:51:27 -0400
parents 0303fda3e929
children
line wrap: on
line diff
--- a/libinterp/interpfcn/pr-output.cc	Tue Mar 19 16:00:09 2013 -0700
+++ b/libinterp/interpfcn/pr-output.cc	Tue Mar 19 20:51:27 2013 -0400
@@ -605,23 +605,24 @@
         fmt = float_format ();
       else
         {
-          int ex = 4;
-          if (digits > 100)
-            ex++;
+          // e+ddd
+          int ex = 5;
 
           if (print_eng)
             {
-              fw = 4 + prec + ex;
+              // -ddd.
+              fw = 5 + prec + ex;
               if (inf_or_nan && fw < 6)
                 fw = 6;
               fmt = float_format (fw, ex, prec - 1, std::ios::fixed);
             }
           else
             {
-              fw = 2 + prec + ex;
+              // -d.
+              fw = 3 + prec + ex;
               if (inf_or_nan && fw < 4)
                 fw = 4;
-              fmt = float_format (fw, prec - 1, std::ios::scientific);
+              fmt = float_format (fw, ex, prec - 1, std::ios::scientific);
             }
         }