# HG changeset patch # User Rik # Date 1569992761 25200 # Node ID 6e8dac65d40570e414f9ab8f13769575aa372881 # Parent fdcec1c0842a9506d2b44cfc9afd0b4727a76f4d Switch to scientific notation for format short when values are large or small (bug #56971). * pr-output.cc (make_real_format, make_real_matrix_format, make_complex_format, make_complex_matrix_format, make_range_format): Switch to scientific notation when number of significant digits (ld + rd) exceeds 1.5 * output_precision. diff -r fdcec1c0842a -r 6e8dac65d405 libinterp/corefcn/pr-output.cc --- a/libinterp/corefcn/pr-output.cc Mon Sep 30 11:29:02 2019 -0700 +++ b/libinterp/corefcn/pr-output.cc Tue Oct 01 22:06:01 2019 -0700 @@ -417,7 +417,8 @@ if (! (rat_format || bank_format || hex_format || bit_format) && (print_e || print_g || print_eng || ld + rd > pr_output_traits::digits10 - || fw > pr_output_traits::max_field_width)) + || fw > pr_output_traits::max_field_width + || ld + rd > (1.5 * prec))) { if (print_g) fmt = float_format (prec, prec); @@ -599,7 +600,8 @@ && (print_e || print_eng || print_g || (! Vfixed_point_format && (ld + rd > pr_output_traits::digits10 - || fw > pr_output_traits::max_field_width)))) + || fw > pr_output_traits::max_field_width + || ld + rd > (1.5 * prec))))) { if (print_g) fmt = float_format (prec+6, prec); @@ -785,7 +787,8 @@ && (print_e || print_eng || print_g || ld + rd > pr_output_traits::digits10 || r_fw > pr_output_traits::max_field_width - || i_fw > pr_output_traits::max_field_width)) + || i_fw > pr_output_traits::max_field_width + || ld + rd > (1.5 * prec))) { if (print_g) { @@ -1022,7 +1025,8 @@ || (! Vfixed_point_format && (ld + rd > pr_output_traits::digits10 || r_fw > pr_output_traits::max_field_width - || i_fw > pr_output_traits::max_field_width)))) + || i_fw > pr_output_traits::max_field_width + || ld + rd > (1.5 * prec))))) { if (print_g) { @@ -1241,7 +1245,8 @@ && (print_e || print_eng || print_g || (! Vfixed_point_format && (ld + rd > pr_output_traits::digits10 - || fw > pr_output_traits::max_field_width)))) + || fw > pr_output_traits::max_field_width + || ld + rd > (1.5 * prec))))) { if (print_g) fmt = float_format (prec+6, prec);