octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: format short output with small numbers (bug #56936)


From: John W. Eaton
Subject: Re: format short output with small numbers (bug #56936)
Date: Tue, 24 Sep 2019 13:19:43 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0

On 9/23/19 5:14 PM, Rik wrote:
All,

What should happen when we display small numbers with "format short"
(default)?  Should we end up printing a lot of zeros?  That is what happens
now.

x = [-pi;0;pi];
x*1e-6
ans =

   -0.0000031416
               0
    0.0000031416

In earlier Octave versions we would switch over to scientific notation at a
certain point.  These are the results from version 3.4.3

octave-3.4.3:5> x*1e-3
ans =

   -0.0031416
    0.0000000
    0.0031416

octave-3.4.3:6> x*1e-4
ans =

   -3.1416e-04
    0.0000e+00
    3.1416e-04

As I recall, Matlab uses a multiplier (Octave's fixed_point_format setting that is enabled when using --traditional). But that doesn't account for the case you show above where it may show 0.00000 for small values instead of showing any digits. For example, something like

  fixed_point_format (true);
  pi * [1e6; 1e-6]

I chose to switch automatically to avoid confusion because people might think that "0.00000" is exactly zero. At that time, I don't remember Matlab displaying "0" to mean "exactly zero" (a feature that I like, BTW, thanks for making that change).

For those who want the display to be more like Matlab, is it sufficient to set fixed_point_format to true? If so, then I'm not sure that there is anything we need to change, unless you are proposing that we enable fixed_point_format by default.

jwe



reply via email to

[Prev in Thread] Current Thread [Next in Thread]