changeset 27430:ba3fc70ba996

Correctly print "format g" when variable is of single type (bug #56926). * pr-output.cc (make_real_format, make_real_matrix_format, make_complex_format, make_complex_matrix_format, make_range_format): When calling float_format constructor, use precision determined to be the minimum of the output_precision or the number of significant digits.
author Rik <rik@octave.org>
date Fri, 20 Sep 2019 13:19:11 -0700
parents e0134184c1fd
children 170d05ce158f
files libinterp/corefcn/pr-output.cc
diffstat 1 files changed, 3 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/pr-output.cc	Fri Sep 20 11:44:44 2019 -0700
+++ b/libinterp/corefcn/pr-output.cc	Fri Sep 20 13:19:11 2019 -0700
@@ -418,10 +418,7 @@
           || fw > pr_output_traits<T>::max_field_width))
     {
       if (print_g)
-        {
-          int prec = output_precision ();
-          fmt = float_format (prec+5, prec);
-        }
+        fmt = float_format (prec+5, prec);
       else
         {
           // e+ddd
@@ -585,10 +582,7 @@
                   || fw > pr_output_traits<T>::max_field_width))))
     {
       if (print_g)
-        {
-          int prec = output_precision ();
-          fmt = float_format (prec+5, prec);
-        }
+        fmt = float_format (prec+5, prec);
       else
         {
           int ex = 4;
@@ -763,7 +757,6 @@
     {
       if (print_g)
         {
-          int prec = output_precision ();
           int width = prec + 5;
           r_fmt = float_format (width, prec);
           i_fmt = float_format (width, prec);
@@ -989,7 +982,6 @@
     {
       if (print_g)
         {
-          int prec = output_precision ();
           int width = prec + 5;
           r_fmt = float_format (width, prec);
           i_fmt = float_format (width, prec);
@@ -1196,10 +1188,7 @@
                   || fw > pr_output_traits<T>::max_field_width))))
     {
       if (print_g)
-        {
-          int prec = output_precision ();
-          fmt = float_format (prec+5, prec);
-        }
+        fmt = float_format (prec+5, prec);
       else
         {
           int ex = 4;